Commit Graph

181 Commits

Author SHA1 Message Date
Ivan Enderlin
eb5e9928b4 src: support ACL (WebDAV, RFC3744, Section 8.1).
PR-URL: https://github.com/joyent/http-parser/pull/260
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-07-20 23:30:14 -07:00
Ivan Enderlin
8b1d652322 src: support BIND/REBIND/UNBIND (WebDAV, RFC5842)
Support BIND/REBIND/UNBIND methods, see sections 4, 5, 6 of
RFC5842.

PR-URL: https://github.com/joyent/http-parser/pull/242
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-07-15 20:22:56 -07:00
Tatsuhiro Tsujikawa
7d75dd7325 src: support IPv6 Zone ID as per RFC 6874
IPv6 scoped address contains Zone ID, which is appended to IPv6
address after '%' separator.  RFC 6874 says that Zone ID after '%'
must consist of 1*(unreserved or pct-encoded).  This commit adds this
IPv6 Zone ID support.

PR-URL: https://github.com/joyent/http-parser/pull/253
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-07-05 11:50:46 -07:00
dlmeetei@gmail.com
ab0b162ef6 src: use ARRAY_SIZE instead of sizeof()
PR-URL: https://github.com/joyent/http-parser/pull/252
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-07-03 20:44:11 -07:00
Jan Schär
39ff0975c2 src: remove double check
This is already included in `http_message_needs_eof`.

PR-URL: https://github.com/joyent/http-parser/pull/248
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-05-21 14:36:28 +02:00
Daniel Knoppel (Phusion)
f6f436a12e src: fix invalid memory access in http_parse_host
http_parse_host() depends on `u->field_data[UF_HOST]`, but this
if() allowed the method to be called if only
`u->field_data[UF_SCHEMA]` was set, resulting in use of
unintialized pointers.

PR-URL: https://github.com/joyent/http-parser/pull/246
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-05-19 17:16:59 +02:00
Kjell Schubert
dff604db20 src: support body in Upgrade requests
Invoke message_complete cb for upgrade with body.

(D1364677 + D1380182 orig author afrind@fb.com)

Fix: #234
PR-URL: https://github.com/joyent/http-parser/pull/235
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-04-23 12:19:26 +02:00
Kjell Schubert
d7675453a6 src: callbacks chunk boundaries: header/complete
(Proxygen fork merge D508755 D521404, orig author simpkins@fb.com)

Fix: #231
PR-URL: https://github.com/joyent/http-parser/pull/233
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-04-23 11:54:47 +02:00
Fedor Indutny
7ecf775d71 src: partially revert 959f4cb to fix nread value
With 959f4cb on reexecution - header byte was accounted twice, leading
to the incorrect `parser->nread` value.

Fix: #220
PR-URL: https://github.com/joyent/http-parser/pull/221
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-19 13:14:54 +01:00
Romain Giraud
53063b780b Add function to initialize http_parser_settings
PR-URL: https://github.com/joyent/http-parser/pull/215
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-26 14:47:29 +03:00
Fedor Indutny
59569f2125 src: skip lws between connection values
Fix: https://github.com/iojs/io.js/issues/588
PR-URL: https://github.com/joyent/http-parser/pull/216
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-25 21:20:49 +03:00
Fedor Indutny
280af6984c src: fix build on MSVC
Do explicit casts from/to enums, convert type of `memchr`'s return value
to `const char*`.

PR-URL: https://github.com/joyent/http-parser/pull/213
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-14 15:58:09 +03:00
Fedor Indutny
3f7ef500bd src: annotate with likely/unlikely
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-12-05 18:13:25 +03:00
Jon Kolb
091ebb8778 src: simple Connection header multi-value parsing
Reviewed-By: Fedor Indutny <fedor@indutny.com>
PR-URL: https://github.com/joyent/http-parser/pull/100
2014-12-05 17:00:06 +03:00
Fedor Indutny
959f4cb127 src: remove reexecute goto 2014-11-29 03:22:11 +03:00
Fedor Indutny
0097de5895 src: use memchr() in h_general header value 2014-11-29 03:22:11 +03:00
Fedor Indutny
c6097e1d76 src: faster general header value loop 2014-11-28 23:53:49 +03:00
Fedor Indutny
263006044a src: less loads in header_value loop 2014-11-28 23:34:36 +03:00
Fedor Indutny
0cb0ee672c src: tighten header field/value loops 2014-11-28 23:30:39 +03:00
Fedor Indutny
6132d1fefa src: save progress 2014-11-28 23:00:08 +03:00
Jeff Pinner
0b43367131 http_parser: Follow RFC-7230 Sec 3.2.4
RFC-7230 Sec 3.2.4 expressly forbids line-folding in header
field-names.

This change no longer allows obsolete line-folding between the
header field-name and the colon. If HTTP_PARSER_STRICT is unset,
the parser still allows space characters.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-09 17:37:27 +01:00
Alexis La Goutte
5b951d74bd src: fix clang warning
Fix http_parser.c:2147:3: warning: Value stored to 'uf' is never
read found by Clang Analyser.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-05 20:28:43 +04:00
Helge Heß
1317eeca43 Added support for MKCALENDAR
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-27 13:28:56 +04:00
Vinnie Falco
24e2d2d43f Allow HTTP_MAX_HEADER_SIZE to be defined externally 2014-03-17 14:31:29 +04:00
David Wragg
76f0f1690f Fix issues around multi-line headers
Always discard leading whitespace in a header value, even if it
is folded.

Pay attention to values of interesting headers (Connection,
Content-Length, etc.) even when they come on a continuation line.

Add a test case to check that requests and responses using only LF
to separate lines are handled correctly.
2014-03-12 20:48:15 +04:00
David Wragg
5d9c382172 Include separating ws when folding header values
The support for folding of multi-line header values does not conform
to the specs.  Given a request containing

    Multi-Line-Header: foo<CRLF>
     bar<CRLF>

http-parser will eliminate the whitespace breaking the header value to
yield a header value of "foobar".  This is confirmed by the
LINE_FOLDING_IN_HEADER case in tests.c.

But from rfc2616, section 2.2:

   A CRLF is allowed in the definition of TEXT only as part of a header
   field continuation. It is expected that the folding LWS will be
   replaced with a single SP before interpretation of the TEXT value.

And from draft-ietf-httpbis-p1-messaging-25, section 3.2.4:

   A server that receives an obs-fold in a request message that is not
   within a message/http container MUST either reject the message by
   sending a 400 (Bad Request), preferably with a representation
   explaining that obsolete line folding is unacceptable, or replace
   each received obs-fold with one or more SP octets prior to
   interpreting the field value or forwarding the message downstream.

So in the example above, the header value should be interpreted as
"foo bar", possibly with multiple spaces.  The current http-parser
behaviour of eliminating the LWS altogether clearly deviates from the
specs.

For http-parser itself to confirm exactly would involve significant
changes in order to synthesize replacement SP octets.  Such changes
are unlikely to be worth it to support what is an obscure and
deprecated feature.  But http-parser should at least preserve some
separating whitespace when folding multi-line header values, so that
applications using http-parser can conform to the specs.

This commit is a minimal change to preserve whitespace when folding
lines.  It eliminates the CRLF, but retains any trailing and leading
whitespace in the header value.
2014-03-12 20:47:50 +04:00
Alexis Campailla
a252d4eebc fix content-length and chunk-size overflow test
The overflow check didn't work for all possible inputs.
2014-01-27 21:17:02 +04:00
Patrik Stutz
d7b938bdca Parse and emit status message of response 2013-12-19 15:56:06 +04:00
Ben Noordhuis
f5c779bb85 Update misleading comment.
The HTTP_MAX_HEADER_SIZE check is not there to guard against
buffer overflows, it's there to protect unwitting embedders
against denial-of-service attacks.
2013-10-21 22:24:40 +02:00
Ben Noordhuis
547553b090 Further request method check strengthening. 2013-08-21 03:29:33 +02:00
Chris Dickinson
c6ee6ada69 Do not accept PUN/GEM methods as PUT/GET.
* Encountering them returns an error, `HPE_INVALID_METHOD`
* Tests have been added.
2013-08-21 02:48:14 +02:00
Ben Noordhuis
d3264312e1 Add function http_parser_version().
Fixes #115.
2013-08-21 02:48:14 +02:00
Tóth Tamás
0938fe599f Add on_status_complete callback.
Add a "status complete" callback to support Simple-Response handling with HTTP
version <= 1.0.

Patch by Tóth Tamás, tests by Corey Richardson.
2012-12-17 14:56:05 +01:00
Corey Richardson
1c7f8cac9e Fix IPv6 address parsing.
Fixes #133.
2012-12-05 04:16:48 +01:00
Ben Noordhuis
245f6f0078 Remove HTTP_PARSER_DEBUG macro.
Remove the HTTP_PARSER_DEBUG macro for two reasons:

* It changes the size of struct http_parser, resulting in spurious memory
  corruption bugs if part of your application is built with HTTP_PARSER_DEBUG=1
  and other parts with HTTP_PARSER_DEBUG=0.

* It's a debugging tool for maintainers. It should never have been exposed in
  the API in the first place.
2012-11-10 23:39:34 +01: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
ad3b631d4f Turn normal_url_char into a bit array.
Makes http_parser slightly more cache friendly.
2012-08-30 00:04:09 +02:00
Ben Noordhuis
add3018ce7 Add bounds check to http_method_str(). 2012-08-29 23:22:53 +02:00
Ben Noordhuis
9f92347851 Make http_should_keep_alive() const correct. 2012-08-29 23:13:16 +02:00
Bertrand Paquet
a828edaf6a Add a comment 2012-07-25 00:36:04 +02:00
Bertrand Paquet
50faa793f4 Coding style : remove space before ++ 2012-07-25 00:20:03 +02:00
Bertrand Paquet
148984cd8d Rename s_req_host* to be compliant with RFC 2396 2012-07-25 00:16:53 +02:00
Bertrand Paquet
7f1b191d6f Minor speed improvment 2012-07-25 00:13:54 +02:00
Bertrand Paquet
d2ce562338 Use new state instead of pointer 2012-07-17 08:48:46 +02:00
Bertrand Paquet
bb29f43741 Coding style improvment 2012-07-17 08:37:39 +02:00
Bertrand Paquet
f6f761596e Small refactoring, add edge cases 2012-07-08 11:58:18 +02:00
Bertrand Paquet
7965096276 User info implementation 2012-07-08 02:04:12 +02:00
Bertrand Paquet
ed8475d49f Refactor host parsing to allow basic auth management 2012-07-08 02:04:07 +02:00
Ben Noordhuis
b97fdb0513 Don't assert() on whitespace in URL.
Be lenient about tabs and form feeds in non-strict mode.
2012-04-23 15:33:57 +02:00
Ben Noordhuis
8bec3ea459 Create method_strings array with HTTP_METHOD_MAP macro. 2012-03-12 02:18:35 +01:00