Module: kamailio
Branch: 4.4
Commit: 63dea59a507c1e949c4eb605ca5b56163b25c8d4
URL: 
https://github.com/kamailio/kamailio/commit/63dea59a507c1e949c4eb605ca5b56163b25c8d4

Author: Federico Cabiddu <federico.cabi...@gmail.com>
Committer: Federico Cabiddu <fcabi...@libon.com>
Date: 2016-05-17T14:57:05+02:00

http_async_client: workaround for dealing with HTTP Via format in replies

(cherry picked from commit 2449f8591261b207c091f9a44ce6cf40bdb71ab6)

---

Modified: modules/http_async_client/async_http.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/63dea59a507c1e949c4eb605ca5b56163b25c8d4.diff
Patch: 
https://github.com/kamailio/kamailio/commit/63dea59a507c1e949c4eb605ca5b56163b25c8d4.patch

---

diff --git a/modules/http_async_client/async_http.c 
b/modules/http_async_client/async_http.c
index d1e9f6e..24dc8ba 100644
--- a/modules/http_async_client/async_http.c
+++ b/modules/http_async_client/async_http.c
@@ -94,6 +94,26 @@ int async_http_init_sockets(async_http_worker_t *worker)
        return 0;
 }
 
+static inline char *strfindcasestrz(str *haystack, char *needlez)              
                                                                                
                                                                                
                                
+{
+    int i,j;
+    str needle;
+
+    needle.s = needlez;
+    needle.len = strlen(needlez);
+    for(i=0;i<haystack->len-needle.len;i++) {
+        for(j=0;j<needle.len;j++) {
+            if ( !((haystack->s[i+j]==needle.s[j]) ||
+                    ( isalpha((int)haystack->s[i+j])
+                        && ((haystack->s[i+j])^(needle.s[j]))==0x20 )) )
+                break;
+        }
+        if (j==needle.len)
+            return haystack->s+i;
+    }
+    return 0;
+}
+
 void async_http_cb(struct http_m_reply *reply, void *param)
 {
        async_query_t *aq;
@@ -101,6 +121,7 @@ void async_http_cb(struct http_m_reply *reply, void *param)
        unsigned int tindex;
        unsigned int tlabel;
        struct cell *t = NULL;
+       char *p;
        sip_msg_t *fmsg;
 
        if (reply->result != NULL) {
@@ -119,6 +140,18 @@ void async_http_cb(struct http_m_reply *reply, void *param)
                ah_error.len = strlen(ah_error.s);
        } else {
                /* success */
+               
+               /* check for HTTP Via header
+        * - HTTP Via format is different that SIP Via
+        * - workaround: replace with Hia to be ignored by SIP parser
+        */
+       if((p=strfindcasestrz(reply->result, "\nVia:"))!=NULL)
+       {
+               p++;
+               *p = 'H';
+               LM_DBG("replaced HTTP Via with Hia [[\n%.*s]]\n", 
reply->result->len, reply->result->s);
+       }
+
                ah_reply->buf = reply->result->s;
                ah_reply->len = reply->result->len;
 


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to