diff options
Diffstat (limited to 'http_parser.rl')
-rw-r--r-- | http_parser.rl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/http_parser.rl b/http_parser.rl index 0685d27..835ba65 100644 --- a/http_parser.rl +++ b/http_parser.rl @@ -62,7 +62,12 @@ static char *skip_header(struct mog_http *http, char *buf, const char *pe) content_length = "Content-Length:"i sep (digit+) $ { - if (!length_incr(&http->_p.content_len, fc)) + /* + * RFC 7230 3.3.2, 3.3.3,: + * favor Transfer-Encoding over Content-Length + */ + if (!http->_p.chunked && + !length_incr(&http->_p.content_len, fc)) fbreak; } $! { errno = EINVAL; fbreak; } @@ -116,7 +121,11 @@ static char *skip_header(struct mog_http *http, char *buf, const char *pe) # "compress" as described in RFC 7230, so reject them, here. "chunked"i $! { errno = EINVAL; fbreak; } - eor @ { http->_p.chunked = 1; }; + eor @ { + http->_p.chunked = 1; + /* RFC 7230 3.3.2, 3.3.3,: ignore length if chunked */ + http->_p.content_len = 0; + }; trailer = "Trailer:"i sep (("Content-MD5"i @ { http->_p.has_md5 = 1; }) | header_name | ',') |