224 Commits

Author SHA1 Message Date
Ben Noordhuis
da918522ca Eat CRLF between requests, even on connection:close.
Fixes #47.
2012-04-14 23:09:30 +02:00
koichik
b47c44d7a6 Fix response body is not read
With HTTP/1.1, if neither Content-Length nor Transfer-Encoding is present,
section 4.4 of RFC 2616 suggests http-parser needs to read a response body
until the connection is closed (except the response must not include a body)

See also joyent/node#2457.
Fixes #72
2012-01-05 22:17:12 -08: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
Felix Geisendörfer
2498961231 Accept HTTP/0.9 responses
See joyent/node#1711
2011-11-22 12:51:01 -08:00
Paul Querna
f1d48aa31c Move all data to before code to fix http parser for c89. 2011-10-02 00:36:16 -04:00
Cliff Frey
c0ecab0516 Merge pull request #61 from bnoordhuis/master
Single-bit bitfield 'upgrade' should be unsigned.
2011-08-29 14:10:43 -07: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
918a071542 Peter Bright's VC fixes 2011-08-06 22:38:22 -07:00
Ryan Dahl
965f91bc76 Support MSVS 2011-08-06 02:55:51 -07:00
Ryan Dahl
ec74d9294c Add GYP file for integration into GYP projects. 2011-08-06 02:54:29 -07:00
Peter Griess
f832bf3b21 Merge pull request #57 from fmardini/master
A struct member rename for compatibility with errno.h
2011-07-24 12:36:38 -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
31ee648709 Cleanup doc references to removed CBs. 2011-07-20 17:08:24 -05:00
Peter Griess
6bc88cc6e9 Merge pull request #54 from pgriess/path-query-frag-callbacks
API CHANGE: Remove path, query, fragment CBs.
2011-07-20 10:17:32 -07: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
49faf2e9cd Merge pull request #53 from pgriess/callback_noclear
Get rid of CALLBACK_NOCLEAR().
2011-07-20 10:06:46 -07:00
Peter Griess
1e071a5087 Merge pull request #52 from pgriess/errno
Break out errno into its own field.
2011-07-20 10:05:49 -07:00
Peter Griess
5469827542 Get rid of CALLBACK_NOCLEAR().
- This was only used by CALLBACK() (which then cleared the mark anyway),
  and the end of the http_parser_execute() body (after which they
  go out of scope).
2011-07-09 13:57:17 -05:00
Peter Griess
761a5eaeb1 Break out errno into its own field. 2011-07-09 11:51:13 -05:00
Peter Griess
1786fdae36 Merge pull request #51 from kolbyjack/is_alpha
Group POST refinements, test all request methods, make IS_ALPHA use LOWER
2011-06-20 12:06:36 -07:00
Jon Kolb
8153466643 Group POST refinements, test all request methods, make IS_ALPHA use LOWER internally 2011-06-20 12:42:57 -04:00
Peter Griess
8e8344518e Re-jigger Makefile.
- Uses more standard $CFLAGS and $CPPFLAGS variables to populate the set
  of flags to build with.
- Allow extending compilation and linking flags with
  $CPPFLAGS_DEBUG_EXTRA, $CPPFLAGS_FAST_EXTRA, $CFLAGS_DEBUG_EXTRA, and
  $CFLAGS_FAST_EXTRA.

Closes #40.
2011-06-19 14:14:17 -05:00
Peter Griess
0aa3e522eb Merge pull request #43 from pgriess/error-reporting
Facility to report detailed parsing errors.
2011-06-19 11:25:39 -07: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
Peter Griess
ddbbc07c10 Fix minor compilation bug introduced by merge. 2011-06-19 13:09:51 -05:00
Peter Griess
056bcd3672 Merge pull request #49 from pgriess/upgrade-off-by-one
Fix off-by-one in handling upgrade bodies.
2011-06-19 10:51:23 -07:00
Peter Griess
d4ca280af5 Fix off-by-one in handling upgrade bodies.
- When handling upgraded bodies, http_parser_execute() used to return
  one fewer bytes parsed than expected. This caused the final LF to be
  interpreted by the caller as part of the body.
- Add a bunch of upgrade body unit tests.
2011-06-18 18:57:32 -05:00
Cliff Frey
d5f0312eee remove unused LOWER(ch) 2011-06-18 11:47:02 -07:00
Cliff Frey
5bb958a9f4 Merge pull request #48 from kolbyjack/master
Allow uppercase chars in IS_ALPHANUM
2011-06-18 11:46:32 -07:00
Jon Kolb
a6934445e8 Allow uppercase chars in IS_ALPHANUM 2011-06-18 13:46:29 -04:00
Peter Griess
f684abdcc5 Merge pull request #27 from a2800276/master
lowercasing in header after check for CR LF
2011-06-11 09:36:30 -07:00
Peter Griess
e1d79e1940 Merge pull request #46 from kolbyjack/master
Also return error for bad requests starting with M or C
2011-06-11 09:25:06 -07:00
Jon Kolb
dc314a3cb9 Return error when bad method starts with M or C 2011-06-10 13:36:36 -04:00
Cliff Frey
d34a2ad26c Merge pull request #45 from scunningham/tracking
Support multi-line folding in header values.
2011-06-03 18:18:31 -07:00
Sean Cunningham
b89f94414e Support multi-line folding in header values.
Normal value cb is called for subsequent lines.  LWS is skipped.
  Note that \t whitespace character is now supported after header field name.

  RFC 2616, Section 2.2
  "HTTP/1.1 header field values can be folded onto multiple lines if the
   continuation line begins with a space or horizontal tab. All linear
   white space, including folding, has the same semantics as SP. A
   recipient MAY replace any linear white space with a single SP before
   interpreting the field value or forwarding the message downstream."
2011-06-03 19:25:54 -04:00
Cliff Frey
3258e4a455 Fix build when char is unsigned by default.
I tested by building/testing with -funsigned-char.  Thanks to apaprocki for
pointing out this problem.
2011-06-03 14:15:33 -07: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
1efd9ac6a0 Number HOSTNAME_UNDERSCORE test 2011-06-03 14:06:32 +02:00
Peter Griess
3bd18a779e IS_* macros for char classes.
- Add IS_ALPHA(), IS_NUM(), IS_HOST_CHAR(), etc. macros for determining
  membership in a character class. HTTP_PARSER_STRICT causes some of
  these definitions to change.
- Support '_' character in hostnames in non-strict mode.
- Support leading digits in hostnames when the method is HTTP_CONNECT.
- Don't re-define HTTP_PARSER_STRICT in http_parser.h if it's already
  defined.
- Tweak Makefile to run non-strict-mode unit tests. Rearrange non-strict
  mode unit tests in test.c.
- Add test_fast to .gitignore.

Fixes #44
2011-05-27 22:26:40 -07:00
Salman
fb23d15ace Add 'package' target in Makefile which produces libhttp_parser.a 2011-05-24 11:28:29 -07: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
8dabce6ec7 It was pointed out we're missing attribution to NGINX 2011-05-15 13:02:20 -07:00
Ryan Dahl
32c0e11583 bump to v1.0 v1.0 2011-05-11 20:57:36 -07:00
Peter Griess
9639c7c21c Support ?-terminated hostnames per RFC 2396.3.2.
- Bust out of s_req_host and s_req_port on '?'.
- Add tests for query string parsing.

Fixes #38.
2011-05-11 11:52:35 -07:00
Peter Griess
50b9bec552 Allow octets > 127 in path components.
- This is non-spec behavior, but it appears that most HTTP servers
  implicitly support non-ASCII characters when parsing path components.
  Extend http-parser to allow this.
- Fill out slots [128, 256) in normal_url_char[] with 1 so that these
  high octets are accepted in path components.
- Add unit test for paths that include such non-ASCII characters.

Fixes #37.
2011-05-11 10:30:29 -07:00
Ryan Dahl
63daf22f2c Update copyright headers 2011-03-22 13:30:24 -07:00
Sean Cunningham
10270007bc Avoid chunk header parsing overflow.
Recharacterize the chunk header states such that they are bound by the check
for HTTP_MAX_HEADER_SIZE.
2011-02-25 09:52:32 -08:00
Sean Cunningham
81ca70aec1 Avoid chunk trailer overflow.
Check for overflow during chunk trailer by removing unnecessary check in macro PARSING_HEADER.  This will force the parser to abort if the chunk trailer contains more than HTTP_MAX_HEADER_SIZE of data.
2011-02-25 09:51:44 -08:00
Ryan Dahl
1c3624a963 Detect errors on EOF 2011-02-04 15:57:09 -08:00