Commit Graph

91 Commits

Author SHA1 Message Date
Ben Noordhuis
3fb4e061ec Bump to version 2.0 2012-10-10 22:38:20 +02:00
BogDan Vatra
1ca7de5258 Add "int http_body_is_final(const http_parser *parser)" method.
It's useful to check if the current chunk is the last one.
2012-09-01 03:04:48 +02:00
Ben Noordhuis
9f92347851 Make http_should_keep_alive() const correct. 2012-08-29 23:13:16 +02:00
Ben Noordhuis
2b7e87cc77 Fix bad http_should_keep_alive() comment. 2012-07-27 01:34:57 +02:00
Peter Griess
ba5acd532f Merge pull request #104 from simonz05/patch-1
Correct misspelling in http_parser.h
2012-07-24 18:06:54 -07:00
Peter Griess
fb3eeb7d05 Merge pull request #118 from bpaquet/master
#116 : refactor to allow url with basic auth a:b@toto.com
2012-07-24 18:02:19 -07:00
James McLaughlin
8ee3b0dc93 Make size_t and ssize_t Windows typedefs more appropriate 2012-07-16 01:58:31 +02:00
Bertrand Paquet
7965096276 User info implementation 2012-07-08 02:04:12 +02:00
Simon
905e959130 Correct misspelling in http_parser.h 2012-03-19 22:44:48 +01:00
Ben Noordhuis
8bec3ea459 Create method_strings array with HTTP_METHOD_MAP macro. 2012-03-12 02:18:35 +01:00
Nathan Rajlich
a3373d7627 add support for "SEARCH" request methods 2012-03-12 01:51:40 +01:00
Ben Noordhuis
36808f4fad Replace HTTP methods enum with X-macro map.
Makes it easier for integrators to generate bindings for the HTTP methods that
we support. Example:

    // stringify method names
    const char *methods[] = {
    #define XX(num, name) #name,
    HTTP_METHOD_MAP(XX)
    #undef XX
    };
2012-02-27 23:35:49 +01:00
Ben Noordhuis
efb72f175c Remove unused struct http_parser_result from header. 2012-02-26 01:29:53 +01:00
Ben Noordhuis
62110efe7a Support PURGE request method.
Fixes joyent/node#2775.
2012-02-20 16:07:00 +01:00
Randy Rizun
b215eaa749 removed obsolete CB_path, CB_query_string and CB_fragment 2012-02-15 13:34:27 +01:00
Ben Noordhuis
f668e72380 Make content_length unsigned, add overflow checks. 2012-01-27 20:49:29 +01:00
Peter Griess
d0bb867d1b Implement http_parser_pause().
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
2012-01-08 20:43:35 -06:00
Peter Griess
d7675cd9a6 Add http_parser_parse_url().
- 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.
2012-01-07 16:53:11 -06:00
Ryan Dahl
3cf68f9a70 Fix compilation on MSVC 2008 which doesn't bundle stdint.h
Thanks to Steve Ridout for the patch. Fixes #69.
2011-12-13 09:37:51 -08:00
Ben Noordhuis
75dc103fd0 Single-bit bitfield 'upgrade' should be unsigned.
Fixes sparse error report: dubious one-bit signed bitfield.
2011-08-29 22:33:38 +02:00
Ryan Dahl
965f91bc76 Support MSVS 2011-08-06 02:55:51 -07:00
Fouad Mardini
2b2ba2da1a rename parser->errno to parser->http_errno; conflicts with errno.h where errno is defined as a macro 2011-07-24 18:49:54 +03:00
Peter Griess
53adfacad1 API CHANGE: Remove path, query, fragment CBs.
- Get rid of support for these callbacks in http_parser_settings.
- Retain state transitions between different URL portions in
  http_parser_execute() so that we're making the same correctness
  guarantees as before.
- These are being removed because making multiple callbacks for the same
  byte makes it more difficult to pause the parser.
2011-07-20 12:16:07 -05:00
Peter Griess
761a5eaeb1 Break out errno into its own field. 2011-07-09 11:51:13 -05:00
Peter Griess
9114e58a77 Facility to report detailed parsing errors.
- Add http_errno enum w/ values for many parsing error conditions. Stash
  this in http_parser.state if the 0x80 bit is set.
- Report line numbers on error generation if the (new) HTTP_PARSER_DEBUG
  cpp symbol is set. Increases http_parser struct size by 8 bytes in
  this case.
- Add http_errno_*() methods to help turning errno values into
  human-readable messages.
2011-06-19 13:25:03 -05:00
Ryan Dahl
eee60127c0 Support PATCH method
Requested in https://groups.google.com/forum/#!topic/nodejs-dev/iEOyiDkJRLs
2011-06-03 14:08:57 +02:00
Ryan Dahl
2839784927 HTTP_STRICT ifdefs out behavior introduced in 50b9bec
Fixes #37.
2011-05-24 09:08:06 -07:00
Peter Griess
b1c2cf83fd Expose F_* flags as public API.
Fixes #42.
2011-05-24 08:57:13 -07:00
Ryan Dahl
32c0e11583 bump to v1.0 2011-05-11 20:57:36 -07:00
Ryan Dahl
63daf22f2c Update copyright headers 2011-03-22 13:30:24 -07:00
Nathan Rajlich
f825b52b7f Added support for "SUBSCRIBE" and "UNSUBSCRIBE" request methods. 2010-11-21 21:37:57 -08:00
Nathan Rajlich
d56a0700d0 Add support for "M-SEARCH" and "NOTIFY" request methods.
Allow a request path of "*" (for SSDP requests).
2010-11-21 21:37:57 -08:00
Aman Gupta
cae8a96c16 Fix build issues using mingw32 on windows 2010-11-10 21:58:55 -08:00
Ewen Cheslack-Postava
24be793f64 Provide typedefs instead of using stdint.h on Windows. 2010-11-04 20:36:14 -07:00
Cliff Frey
c30ea4515c save 8 bytes in http_parser structure
nread can never be larger than HTTP_MAX_HEADER_SIZE
2010-08-18 11:07:14 -07:00
Ryan Dahl
a59ba4d866 Support long messages 2010-07-26 14:59:39 -07:00
Ewen Cheslack-Postava
4afe80a44e Add definitions and typedefs to support compilation in Visual Studio under C++ mode. 2010-06-28 00:14:25 -07:00
Ryan Dahl
ddbd5c3728 Expose http_method_str() to get a string version of a method 2010-06-23 21:04:57 -07:00
Ryan Dahl
9dc258f9dd Add subversion request methods
REPORT, MKACTIVITY, CHECKOUT, MERGE
2010-06-23 21:04:32 -07:00
Cliff Frey
9eac636531 save more space by removing buffer and shortening method
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.
2010-06-11 15:17:38 -07:00
Cliff Frey
546f43a782 remove body_read
This saves space in the structure (it is now 28 bytes on x86), and
makes the handling of content_length more consistent between chunked
encoding and non-chunked-encoding.
2010-06-11 11:15:06 -07:00
Cliff Frey
8732d108a4 stop tracking lengths of returned values
This drops support for MAX_FIELD_SIZE, and saves 4 more bytes in the
parser object (44 bytes total now).
2010-05-28 12:42:12 -07:00
Cliff Frey
076fa15132 reduce the size of the http_parser struct
The *_mark members were actually being used as just boolean values to
the next call of the parser.  However, you can calculate if the mark
members should be set or not purely based on the current state, so
they can just be gotten rid of entirely.
2010-05-28 12:41:27 -07:00
Cliff Frey
5502cddd35 reduce http_parser from 60 bytes to 48 bytes
This is mostly done by using sized types instead of enums, and
reordering fields to allow better packing.

I also moved the 'upgrade' field out of the PRIVATE section and into
the READ-ONLY section, as I believe that it is supposed to be
non-private.
2010-05-28 01:07:12 -07:00
Cliff Frey
0e8ad4e003 reduce size of http_parser object from 104 to 84 bytes by only tracking one field size
This does have some slight functional changes in cases where
MAX_FIELD_SIZE is hit, specficially if a URL is made up of many
components, each of which is smaller than MAX_FIELD_SIZE, but the
total together is greater than MAX_FIELD_SIZE, then we now might not
call callbacks for any of the components (even the ones that are
smaller than 80kb).  With the old code, it was possible to get a
callback for query_string and never get a callback for the URL (or at
least the end of the URL that is past 80kb), if the callback for the
URL would have been larger than 80kb.

(to be honest, I'm surprised that the MAX_FIELD_SIZE is implemented in
http_parser at all, instead of requiring that callers pay attention to
it, as it feels like it should be the caller's responsibility)
2010-05-28 01:02:16 -07:00
Cliff Frey
b8c3336f5d add support for HTTP_BOTH
This is good for analyzing raw streams of data when one is not sure
which direction it will be in.
2010-05-27 00:40:44 -07:00
Ryan Dahl
c2acc213ac Skip body for HEAD responses
TODO: need test for response with non-zero content length but no body.
2010-05-25 16:35:22 -07:00
Cliff Frey
7239788205 pass pointer to settings structure rather than pass by value 2010-05-11 12:12:23 -07:00
Ryan Dahl
88d11b394d Support Upgrade header 2010-04-14 03:17:11 -07:00
Ryan Dahl
6f72c780f0 Remove stddef include, it's included in http_parser.c 2010-03-13 20:55:55 -08:00