Skip to content

Commit

Permalink
core: tcp - handle http read on \n\n EOH and deal with HTTP Via header
Browse files Browse the repository at this point in the history
- handling \n\n for http makes same code as for sip, being easier to
  test injecting a request from file
- HTTP Via is not compatible with SIP Via, resulting in errors - replace
  its name with Hia to be ignored. FS#237
  • Loading branch information
miconda committed Jan 6, 2015
1 parent 72a616f commit 54c178a
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions tcp_read.c
Expand Up @@ -172,6 +172,16 @@ int tcp_http11_continue(struct tcp_connection *c)
c->req.flags |= F_TCP_REQ_BCHUNKED;
ret = 1;
}
/* 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(&msg, "\nVia:"))!=NULL)
{
p++;
*p = 'H';
LM_DBG("replaced HTTP Via with Hia [[\n%.*s]]\n", msg.len, msg.s);
}
return ret;
}
#endif /* HTTP11 */
Expand Down Expand Up @@ -452,6 +462,10 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
case '\n':
/* found LF LF */
r->state=H_BODY;
#ifdef READ_HTTP11
if (cfg_get(tcp, tcp_cfg, accept_no_cl)!=0)
tcp_http11_continue(c);
#endif
if (TCP_REQ_HAS_CLEN(r)){
r->body=p+1;
r->bytes_to_go=r->content_len;
Expand All @@ -461,9 +475,42 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
goto skip;
}
}else{
DBG("tcp_read_headers: ERROR: no clen, p=%X\n",
*p);
r->error=TCP_REQ_BAD_LEN;
if(cfg_get(tcp, tcp_cfg, accept_no_cl)!=0) {
#ifdef READ_MSRP
/* if MSRP message */
if(c->req.flags&F_TCP_REQ_MSRP_FRAME)
{
r->body=p+1;
/* at least 3 bytes: 0\r\n */
r->bytes_to_go=3;
p++;
r->content_len = 0;
r->state=H_MSRP_BODY;
break;
}
#endif

#ifdef READ_HTTP11
if(TCP_REQ_BCHUNKED(r)) {
r->body=p+1;
/* at least 3 bytes: 0\r\n */
r->bytes_to_go=3;
p++;
r->content_len = 0;
r->state=H_HTTP11_CHUNK_START;
break;
}
#endif
r->body=p+1;
r->bytes_to_go=0;
r->flags|=F_TCP_REQ_COMPLETE;
p++;
goto skip;
} else {
DBG("tcp_read_headers: ERROR: no clen, p=%X\n",
*p);
r->error=TCP_REQ_BAD_LEN;
}
}
break;
case '-':
Expand Down

0 comments on commit 54c178a

Please sign in to comment.