浏览代码

- accept http replies if HTTP_REPLY_HACK is defined (needed for forwarding
xmlrpc request/replies to other sers)

Andrei Pelinescu-Onciul 19 年之前
父节点
当前提交
7b4461e2b2
共有 1 个文件被更改,包括 21 次插入1 次删除
  1. 21 1
      parser/parse_fline.c

+ 21 - 1
parser/parse_fline.c

@@ -42,7 +42,12 @@
 #include "../mem/mem.h"
 #include "../ut.h"
 
-#define HTTP_REPLY_HACK /* allow HTTP replies */
+
+#ifdef NO_HTTP_REPLY_HACK
+#undef HTTP_REPLY_HACK
+#else
+/* #define HTTP_REPLY_HACK */ /* allow HTTP replies */
+#endif
 
 /* grammar:
 	request  =  method SP uri SP version CRLF
@@ -96,6 +101,21 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
 			fl->type=SIP_REPLY;
 			fl->u.reply.version.len=SIP_VERSION_LEN;
 			tmp=buffer+SIP_VERSION_LEN;
+#ifdef HTTP_REPLY_HACK
+	}else if ( 	(*tmp=='H' || *tmp=='h') &&
+		/* 'HTTP/1.' */
+		strncasecmp( tmp+1, HTTP_VERSION+1, HTTP_VERSION_LEN-1)==0 &&
+		/* [0|1] */
+		((*(tmp+HTTP_VERSION_LEN)=='0') || (*(tmp+HTTP_VERSION_LEN)=='1')) &&
+		(*(tmp+HTTP_VERSION_LEN+1)==' ')  ){ 
+		/* ugly hack to be able to route http replies
+		 * Note: - the http reply must have a via
+		 *       - the message is marked as SIP_REPLY (ugly)
+		 */
+			fl->type=SIP_REPLY;
+			fl->u.reply.version.len=HTTP_VERSION_LEN+1 /*include last digit*/;
+			tmp=buffer+HTTP_VERSION_LEN+1 /* last digit */;
+#endif
 	} else IFISMETHOD( INVITE, 'I' )
 	else IFISMETHOD( CANCEL, 'C')
 	else IFISMETHOD( ACK, 'A' )