|
@@ -2667,57 +2667,50 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str *new_tag,
|
|
|
if(unlikely(httpreq))
|
|
|
pvia = p;
|
|
|
if(hdr == msg->h_via1) {
|
|
|
- if(rport_buf) {
|
|
|
- if(msg->via1->rport) { /* delete the old one */
|
|
|
- /* copy until rport */
|
|
|
- append_str_trans(p, hdr->name.s,
|
|
|
- msg->via1->rport->start - hdr->name.s - 1,
|
|
|
- msg);
|
|
|
- /* copy new rport */
|
|
|
- append_str(p, rport_buf, rport_len);
|
|
|
- /* copy the rest of the via */
|
|
|
- append_str_trans(p,
|
|
|
- msg->via1->rport->start
|
|
|
- + msg->via1->rport->size,
|
|
|
- hdr->body.s + hdr->body.len
|
|
|
- - msg->via1->rport->start
|
|
|
- - msg->via1->rport->size,
|
|
|
- msg);
|
|
|
- } else if(msg->via1->branch) { /* add after branch */
|
|
|
- /* copy until after branch */
|
|
|
- append_str_trans(p, hdr->name.s,
|
|
|
- msg->via1->branch->start - hdr->name.s
|
|
|
- + msg->via1->branch->size,
|
|
|
- msg);
|
|
|
- /* copy new rport */
|
|
|
- append_str(p, rport_buf, rport_len);
|
|
|
- /* copy the rest of the via */
|
|
|
- append_str_trans(p,
|
|
|
- msg->via1->branch->start
|
|
|
- + msg->via1->branch->size,
|
|
|
- hdr->body.s + hdr->body.len
|
|
|
- - msg->via1->branch->start
|
|
|
- - msg->via1->branch->size,
|
|
|
- msg);
|
|
|
- } else { /* just append the new one */
|
|
|
- /* normal whole via copy */
|
|
|
- append_str_trans(p, hdr->name.s,
|
|
|
- (hdr->body.s + hdr->body.len) - hdr->name.s,
|
|
|
- msg);
|
|
|
- append_str(p, rport_buf, rport_len);
|
|
|
- }
|
|
|
- } else {
|
|
|
- /* normal whole via copy */
|
|
|
+ if(rport_buf && msg->via1->rport) { /* replace old rport */
|
|
|
+ /* copy until rport */
|
|
|
+ append_str_trans(p, hdr->name.s,
|
|
|
+ msg->via1->rport->start - hdr->name.s - 1, msg);
|
|
|
+ } else if(msg->via1->branch) { /* add after branch */
|
|
|
+ append_str_trans(p, hdr->name.s,
|
|
|
+ msg->via1->branch->start - hdr->name.s
|
|
|
+ + msg->via1->branch->size,
|
|
|
+ msg);
|
|
|
+ } else { /* append after header */
|
|
|
append_str_trans(p, hdr->name.s,
|
|
|
(hdr->body.s + hdr->body.len) - hdr->name.s,
|
|
|
msg);
|
|
|
}
|
|
|
+ if(rport_buf) {
|
|
|
+ /* add rport */
|
|
|
+ append_str(p, rport_buf, rport_len);
|
|
|
+ }
|
|
|
if(received_buf) {
|
|
|
+ /* add received */
|
|
|
append_str(p, received_buf, received_len);
|
|
|
}
|
|
|
if(xparams.len > 0) {
|
|
|
+ /* add extra parameters */
|
|
|
append_str(p, xparams.s, xparams.len);
|
|
|
}
|
|
|
+ /* copy the rest of the via */
|
|
|
+ if(rport_buf && msg->via1->rport) {
|
|
|
+ append_str_trans(p,
|
|
|
+ msg->via1->rport->start
|
|
|
+ + msg->via1->rport->size,
|
|
|
+ hdr->body.s + hdr->body.len
|
|
|
+ - msg->via1->rport->start
|
|
|
+ - msg->via1->rport->size,
|
|
|
+ msg);
|
|
|
+ } else if(msg->via1->branch) {
|
|
|
+ append_str_trans(p,
|
|
|
+ msg->via1->branch->start
|
|
|
+ + msg->via1->branch->size,
|
|
|
+ hdr->body.s + hdr->body.len
|
|
|
+ - msg->via1->branch->start
|
|
|
+ - msg->via1->branch->size,
|
|
|
+ msg);
|
|
|
+ }
|
|
|
} else {
|
|
|
/* normal whole via copy */
|
|
|
append_str_trans(p, hdr->name.s,
|