From c54df54f6633f3467b64fdfc9cbff278d02397ac Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Apr 2010 15:02:46 -0700 Subject: http: pedantic fix for trailer-less chunked requests HTTP requests without trailers still need a CRLF after the last chunk, that is: it must end as: "0\r\n\r\n", not "0\r\n". So we'll always pretend there are trailers to parse for the sake of TeeInput. This is mostly a pedantic fix, as the two bytes in the socket buffer are unlikely to trigger protocol errors. --- ext/unicorn_http/unicorn_http.rl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'ext') diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index f0b602b..264db68 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -299,12 +299,8 @@ static void write_value(VALUE req, struct http_parser *hp, } action end_chunked_body { - if (HP_FL_TEST(hp, HASTRAILER)) { - HP_FL_SET(hp, INTRAILER); - cs = http_parser_en_Trailers; - } else { - cs = http_parser_first_final; - } + HP_FL_SET(hp, INTRAILER); + cs = http_parser_en_Trailers; ++p; assert(p <= pe && "buffer overflow after chunked body"); goto post_exec; -- cgit v1.2.3-24-ge0c7