Without this change, it is possible to get an assertion to fail by continuing to call http_parser_execute after it has returned an error. Specifically, the parser could be called with parser->state == s_chunk_size_almost_done and parser->flags & F_CHUNKED set. Then, F_CHUNKED could have been cleared, and an error could be hit. In this case, the parser would have returned with F_CHUNKED clear, but parser->state == s_chunk_size_almost_done, resulting in an assertion failure on the next call. There are alternate solutions possible, including just saving all of the fields (state included) on error. I didn't add a test case because this is a bit annoying to test, but I can add one if necesssary.
Yay valgrind testing I don't believe that this actually mattered at all, because state was initialized correctly, and flags would be set to 0 almost immediately anyways.
For some reason valgrind would rapidly run out of memory on my machine without this.
…under C++ mode.
This also fixes test failures from the previous commit. It also adds support for the LOCK method, which was previously missing. This brings the size of http_parser from 44 bytes to 32 bytes. It also makes the code substantially shorter, at a slight cost in craziness.
This fixes a possible issue where a very large body (one that involves > 80*1024 calls to http_parser_execute) will cause the next request with that parser to return an error because it believes that this is an overflow condition.