Browse Source

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

Daniel-Constantin Mierla 10 years ago
parent
commit
dfb34a6516
1 changed files with 10 additions and 0 deletions
  1. 10 0
      msg_translator.c

+ 10 - 0
msg_translator.c

@@ -2281,6 +2281,8 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
 	char *after_body;
 	str  to_tag;
 	char *totags;
+	int httpreq;
+	char *pvia;
 
 	body = 0;
 	buf=0;
@@ -2302,6 +2304,8 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
 	/*computes the length of the new response buffer*/
 	len = 0;
 
+	httpreq = IS_HTTP(msg);
+
 	/* check if received needs to be added */
 	if (received_test(msg)) {
 		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,
 		switch (hdr->type)
 		{
 			case HDR_VIA_T:
+				/* if is HTTP, backup start of Via header in response */
+				if(unlikely(httpreq)) pvia = p;
 				if (hdr==msg->h_via1){
 					if (rport_buf){
 						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,
 							(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
 				}
 				append_str( p, CRLF,CRLF_LEN);
+				/* if is HTTP, replace Via with Sia
+				 * - HTTP Via format is different than SIP Via
+				 */
+				if(unlikely(httpreq)) *pvia = 'S';
 				break;
 			case HDR_RECORDROUTE_T:
 				/* RR only for 1xx and 2xx replies */