Before this change it would include the last slash in the separator between the schema and host as part of the host. we cant use the trick used for skipping the separator before ports, query strings, and fragments because if it was a CONNECT style url string (host:port) it would skip the first character of the hostname. Work around this by introducing a few more states to represent these separators in a url differently to what theyre separating. this in turn lets us simplify the url parsing so can simply skip what it considers delimiters rather than having to special case certain types of url parts and skip their prefixes. Add tests for the http_parser_parse_url(). This compares the http_parser_url struct that http_parser_parse_url() produces against one that we expect from the test. If they differ then http_parser_parse_url() misbehaved.
This avoids having to specify -I when building.
Summary: - Add http_parser_pause() API. A callback may invoke this at any time. This will cause http_parser_parse() to return indicating that it parsed less than the number of requested bytes and set an error to HBE_PAUSED. A paused parser with fail with HBE_PAUSED until it is un-paused with http_parser_pause(). - Stop using 'state', 'header_state', 'index', and 'nread' shadow variables and then updating their http_parser fields when we're done. Instead, update the live values as we go. This will make it possible to return from anywhere in the parser (say, due to EPAUSED) and have valid/expected state. - Update state before making callbacks so that if the want to pause, we'll know the correct state already. - Make sure that every callback has a state that uniquely identifies the next step so that we can resume in the right place if we were suppoed to be paused. - Clean and re-factor up CALLBACK() macros. - Use CALLBACK() macros for (almost) all callbacks; on_headers_complete is still a special case. This includes on_body which we used to invoke manually with a long run of bytes. We now use a 'body' mark and hit its callback just like every other data callback. - Clean up (most) gotos and replace with real states. - Add some unit tests. Fixes #70
- Break EOF handling out of http_should_keep_alive() into http_message_needs_eof(), which we now use when determining what to do with a message of unknown length. This prevents us from falling into the s_body_identity_eof state in the cases where we actually *do* know the length of the message (e.g. because the response status was 204).
- Port message length logic from #72 to HTTP/1.0. - Add a bunch of unit tests for handling 0-length messages.
- Add an http_parser_parse_url() method to parse a URL into its constituent components. This uses the same underlying parser as http_parser_parse() and doesn't do any data copies. - Re-add the URL components in various test.c structures; validate them when parsing.
Thanks to Steve Ridout for the patch. Fixes #69.
…ere errno is defined as a macro