Browse code

core: use Sia header name instead of Via for HTTP responses sent out

Daniel-Constantin Mierla authored on 06/01/2015 22:41:59
Showing 1 changed files
... ...
@@ -2281,6 +2281,8 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
2281 2281
 	char *after_body;
2282 2282
 	str  to_tag;
2283 2283
 	char *totags;
2284
+	int httpreq;
2285
+	char *pvia;
2284 2286
 
2285 2287
 	body = 0;
2286 2288
 	buf=0;
... ...
@@ -2302,6 +2304,8 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
2302 2302
 	/*computes the length of the new response buffer*/
2303 2303
 	len = 0;
2304 2304
 
2305
+	httpreq = IS_HTTP(msg);
2306
+
2305 2307
 	/* check if received needs to be added */
2306 2308
 	if (received_test(msg)) {
2307 2309
 		if ((received_buf=received_builder(msg,&received_len))==0) {
... ...
@@ -2410,6 +2414,8 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
2410 2410
 		switch (hdr->type)
2411 2411
 		{
2412 2412
 			case HDR_VIA_T:
2413
+				/* if is HTTP, backup start of Via header in response */
2414
+				if(unlikely(httpreq)) pvia = p;
2413 2415
 				if (hdr==msg->h_via1){
2414 2416
 					if (rport_buf){
2415 2417
 						if (msg->via1->rport){ /* delete the old one */
... ...
@@ -2443,6 +2449,10 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
2443 2443
 							(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
2444 2444
 				}
2445 2445
 				append_str( p, CRLF,CRLF_LEN);
2446
+				/* if is HTTP, replace Via with Sia
2447
+				 * - HTTP Via format is different than SIP Via
2448
+				 */
2449
+				if(unlikely(httpreq)) *pvia = 'S';
2446 2450
 				break;
2447 2451
 			case HDR_RECORDROUTE_T:
2448 2452
 				/* RR only for 1xx and 2xx replies */