Commit Graph

61 Commits

Author SHA1 Message Date
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
6533f8ac9c do not access random memory before lowcase array
This matters because char is signed by default on x86, so bytes with
values above 127 could have theoretically survived a pass through
lowcase (assuming that there was some non-zero data before the lowcase
array).
2010-06-11 17:28:58 -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
2d16d50425 only increment nread while looking at headers
This fixes a possible issue where a very large body (one that involves
> 80*1024 calls to http_parser_execute) will cause the next request
with that parser to return an error because it believes that this is
an overflow condition.
2010-06-11 10:58:42 -07:00
Ryan Dahl
4cf39fd2fa Support request URLs without schema
Test case from Poul T Lomholt <pt@lomholt.com>
2010-06-06 16:18:41 -07:00
Ryan Dahl
cdda8b6a60 Support empty header values
Test case by Pierre Ruyssen <pierre@ruyssen.fr>
2010-06-06 16:01:42 -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
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
Ryan Dahl
8beed7ef17 Fix whitespace 2010-05-27 11:48:13 -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
7cfa645fc7 Fix long chunked message bug
The HTTP_MAX_HEADER_SIZE was being consulted at the end of the chunked
message (when you look for trailing headers).

http://github.com/ry/node/issues#issue/77
2010-04-28 23:21:49 -07:00
Ryan Dahl
88d11b394d Support Upgrade header 2010-04-14 03:17:11 -07:00
Ryan Dahl
da30924dc8 Use stddef.h 2010-03-10 19:52:42 -08:00
Ryan Dahl
a458431e38 Remove string.h include 2010-02-27 21:27:13 -08:00
Ryan Dahl
e07e0b952e Tasteful vertical whitespace. 2010-02-27 21:24:09 -08:00
Ryan Dahl
4bce6b4467 Use nginx-style method compare
If only just to remove dependency on strncmp().
2010-02-27 21:18:08 -08:00
Ryan Dahl
dbd2dad461 Introduce http_parser_settings 2010-02-27 20:31:05 -08:00
Ryan Dahl
ef14734f6c Use marcros instead of inline funcs to do callbacks
Simplifies things.
2010-02-27 20:14:34 -08:00
Ryan Dahl
8243fddd17 Fix c++ and mac compile errors 2010-02-20 17:10:22 -08:00
Ryan Dahl
1b30bf4ba5 Only allow 80kb of header bytes 2010-02-02 16:41:45 -08:00
Cliff Frey
d5a900264f Allow newlines before HTTP requests.
I have seen cases where a browser will POST data, and then send an
extra CRLF before issuing the next request.
2010-02-02 09:17:19 -08:00
Cliff Frey
f167565742 Allow '_' in header fields.
Technically anything defined as a 'token' by
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 should be
allowed, which includes !#$%^&*+-.`~| and probably others.  However
this is the only one that I have found in use.
2010-02-02 09:15:48 -08:00
Cliff Frey
6409a5bd17 Allow extra '?' in query strings, and add a test for it. 2010-02-02 09:14:39 -08:00
Cliff Frey
ae8234de93 Prevent uninitialized variable use 2010-02-02 09:14:15 -08:00
Ryan Dahl
9cbd66e49a Support 'Proxy-Connection' header
See http://www.http-stats.com/Proxy-Connection
2010-01-09 01:16:19 -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
6108b765ce Bugfix: sometimes servers send \n instead of \r\n 2010-01-07 00:52:13 -08:00
Ryan Dahl
b5b116e59e Remove unused 's_headers_done' state 2010-01-06 19:01:03 -08:00
Ryan Dahl
79947a7334 Remove EOL whitespace 2010-01-06 18:54:51 -08:00
Ryan Dahl
402eda40a7 Change flag values to bit shifts 2010-01-06 18:54:39 -08:00
Ryan Dahl
0d6cebd70b wasn't correctly setting method for PROPPATCH and PROPFIND 2009-12-06 23:56:24 +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
d53606f57e Add a macros for the usual case 2009-12-01 05:54:22 +01:00
Ryan Dahl
0cbc9101d0 Use error label, instead of returning directly 2009-11-21 22:54:31 +01:00
Ryan Dahl
51e9ff0314 Fix initialization bug.
Heap allocate parser in tests, to get errors with valgrind.
2009-11-21 21:48:56 +01:00
Ryan Dahl
873912df5e Only use s_dead in STRICT mode. 2009-11-21 17:08:40 +01:00
Ryan Dahl
a8f7a3cd78 add message_complete_on_eof test 2009-11-20 17:05:25 +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
5b37977e32 Don't put should_keep_alive messages in front of messages 2009-11-20 15:59:31 +01:00
Ryan Dahl
8f52d451a6 Add http version to tests 2009-11-20 15:59:31 +01:00
Ryan Dahl
717d04ce2d Optimize increasing the header_index 2009-11-20 15:59:30 +01:00