embedthis/http — pull request #5 by jchampio (2012-06-29 15:53:19+00:00)
Title: HTTP engine does not always parse last "\r\n" in the final chunk

httpFilterChunkData is lenient if a client does not send a final CRLF pair during a chunked request. In other words, instead of requiring ```0\r\n\r\n``` to end the request, a client can get away with just sending ```0\r\n```.

This lenience causes problems for conforming clients, however, if the final CRLF gets split into another packet and is delayed. For example, if a client makes a chunked request and follows it up with an HTTP GET, the bytestream might look like this: ```0\r\n\r\nGET / HTTP/1.1\r\n```. The client intends for this to be parsed as ```0\r\n\r\n``` ```GET / HTTP/1.1\r\n```, but if the packets are split, Appweb may end up parsing the requests as ```0\r\n``` ```\r\nGET / HTTP/1.1\r\n```.

This patch removes the lenient behavior and forces httpFilterChunkData to wait for the final CRLF pair. Note that this patch does not support chunk trailers (defined in [RFC 2616 3.6.1](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1) and used by the [Trailer header](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.40)). Since Appweb does not currently support chunk trailers, I didn't see a need to put that into this patch.