This patch renames the HttpParser class as Http1Parser (to differentiate
from the future planned Http2Parser) and moves it into the Http namespace.
The parser class API
- is updated to process both the request-line and HTTP mime headers,
returning a incomplete parse result until the entire headers parts of
the message have been received.
- now contains accessor methods for retrieving the method, URI,
protocol, mime headers block (as an SBuf) and some metrics about those.
- the old request_offsets structure and similar offset details are no
longer exposed.
The parser is made partially incremental. There is more that can be done
to further speed up parsing of slow or very large requests.
Much of the code from client_side.cc parseHttpRequest() and also the
header-field code from mime_headers.cc has been moved into the parser
class. The client-side code now simply runs the main
Http1Parser::parseReuqest() method then uses its accessors to retrieve
and process the parse results.
A unit test for incremental parsing has been added to testHttpParser.
Also, the HttpRequestMethod class is moved into the Http namespace and
library to reduce dependencies on the parser class outside the library.
Overall this does not seem to affect performance much. We trade one SBuf
allocation+memcpy of the mime headers for preventing several strlen()
scans and reduced headersEnd() overheads). But it does clarify the
parser API and provide a solid base from which to implement the SBuf
Tokeniser for the mime headers block.
Amos
This archive was generated by hypermail 2.2.0 : Thu Jan 02 2014 - 12:00:10 MST