73 Commits

Author SHA1 Message Date
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
Ryan Dahl
e07e0b952e Tasteful vertical whitespace. 2010-02-27 21:24:09 -08:00
Ryan Dahl
dbd2dad461 Introduce http_parser_settings 2010-02-27 20:31:05 -08:00
Ryan Dahl
d37a9c5b9b fix typos 2010-02-22 08:11:01 -08:00
Ryan Dahl
1b30bf4ba5 Only allow 80kb of header bytes 2010-02-02 16:41:45 -08:00
Ryan Dahl
caef58793e Update license for 2010 2010-01-08 21:42:02 -08:00
Ryan Dahl
1a677040c0 API: Define parser type in http_parser_init()
That is, for a request parser do this:

  http_parser_init(my_parser, HTTP_REQUEST)

for a response parser do this:

  http_parser_init(my_parser, HTTP_RESPONSE)

Then http_parse_requests() and http_parse_responses() both turn
into http_parer_execute().
2010-01-08 21:38:17 -08:00
Ryan Dahl
1d9ebac036 Revert "Add method -> string lookup"
This reverts commit b795f94686.

(I don't like this feature, and I'm not using it.)
2010-01-06 19:03:32 -08:00
Ryan Dahl
79947a7334 Remove EOL whitespace 2010-01-06 18:54:51 -08:00
Ryan Dahl
b795f94686 Add method -> string lookup 2009-12-07 15:17:49 +01:00
Ryan Dahl
4aebd8bbb9 reorder methods 2009-12-07 00:15:22 +01:00
Ryan Dahl
9c059ec60d Reimplement support for extension methods
This sacrifices
- a little space (10 bytes),
- a few extra calculations, and
- introduces a dependency on strncmp()
to dramatically simplify the code of parsing methods and support almost
arbitrary extension methods.

In the future I will do as NGINX does and not use strncmp but bit level
blob comparisons.
2009-12-06 23:38:27 +01:00
Ryan Dahl
12808fe1e6 accept webdav methods 2009-12-06 19:13:17 +01:00
Ryan Dahl
bd291ab5d8 add license file 2009-11-20 15:59:31 +01:00
Ryan Dahl
5b00b6a64f add http_should_keep_alive() 2009-11-20 15:59:31 +01:00
Ryan Dahl
ca1e011ab3 add response scan, fix persistent bug 2009-11-20 15:59:30 +01:00
Ryan Dahl
fb6dc67b05 strict check 2009-11-20 15:59:30 +01:00
Ryan Dahl
0642366f0e change around api 2009-11-20 15:59:30 +01:00
Ryan Dahl
b283cd950f copyright header 2009-11-20 15:59:30 +01:00