From 51c1526b6a00bd456d718041c6445527c89359f1 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 6 Nov 2009 12:44:20 +0100 Subject: [PATCH] Revert "Upgrade http parser, change node as needed." Something is broken in how keep-alive is working. Reverting until I can fix it. This reverts commit b893859c34f05db5c45f416949ebc0eee665cca6. --- deps/http_parser/LICENSE | 16 +- deps/http_parser/Makefile | 4 +- deps/http_parser/README.md | 33 +- deps/http_parser/http_parser.c | 5513 +++++++++---------- deps/http_parser/http_parser.h | 91 +- deps/http_parser/http_parser.rl | 236 +- deps/http_parser/test.c | 165 +- lib/http.js | 7 +- src/node_http.cc | 42 +- src/node_http.h | 1 - test/mjsunit/test-http-malformed-request.js | 22 +- test/mjsunit/test-http-proxy.js | 16 +- test/mjsunit/test-http-server.js | 16 +- 13 files changed, 2992 insertions(+), 3170 deletions(-) diff --git a/deps/http_parser/LICENSE b/deps/http_parser/LICENSE index 561e5c5e4f..7fb7fcd191 100644 --- a/deps/http_parser/LICENSE +++ b/deps/http_parser/LICENSE @@ -1,5 +1,4 @@ Copyright 2009, Ryan Lienhart Dahl. All rights reserved. - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the @@ -16,13 +15,16 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. +IN THE SOFTWARE. + + + http_parser is based on Zed Shaw's Mongrel. Mongrel's license is as follows. ----- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- +-- CUT ---- CUT ---- CUT ---- CUT ---- CUT ---- CUT ---- CUT ---- CUT -- Mongrel Web Server (Mongrel) is copyrighted free software by Zed A. Shaw - and contributors. You can redistribute it + and contributors. You can redistribute it and/or modify it under either the terms of the GPL2 or the conditions below: 1. You may make and give away verbatim copies of the source form of the @@ -64,9 +66,9 @@ and/or modify it under either the terms of the GPL2 or the conditions below: software (possibly commercial). But some files in the distribution are not written by the author, so that they are not under this terms. -5. The scripts and library files supplied as input to or produced as +5. The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the - copyright of the software, but belong to whomever generated them, + copyright of the software, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this software. @@ -74,4 +76,4 @@ and/or modify it under either the terms of the GPL2 or the conditions below: IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ----- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- +-- CUT ---- CUT ---- CUT ---- CUT ---- CUT ---- CUT ---- CUT ---- CUT -- diff --git a/deps/http_parser/Makefile b/deps/http_parser/Makefile index 899de241a8..afe7229222 100644 --- a/deps/http_parser/Makefile +++ b/deps/http_parser/Makefile @@ -1,8 +1,8 @@ #OPT=-O0 -g -Wall -Wextra -Werror OPT=-O2 -test: http_parser.o test.c - gcc $(OPT) http_parser.o test.c -o $@ +test: http_parser.o test.c + gcc $(OPT) http_parser.o test.c -o $@ http_parser.o: http_parser.c http_parser.h Makefile gcc $(OPT) -c http_parser.c diff --git a/deps/http_parser/README.md b/deps/http_parser/README.md index 1e77aa5234..d60473ef1b 100644 --- a/deps/http_parser/README.md +++ b/deps/http_parser/README.md @@ -5,11 +5,11 @@ This is a parser for HTTP messages written in C. It parses both requests and responses. The parser is designed to be used in performance HTTP applications. It does not make any allocations, it does not buffer data, and it can be interrupted at anytime. It only requires about 128 bytes of data -per message stream (in a web server that is per connection). +per message stream (in a web server that is per connection). Features: - * No dependencies + * No dependencies * Parses both requests and responses. * Handles keep-alive streams. * Decodes chunked encoding. @@ -43,35 +43,21 @@ When data is received on the socket execute the parser and check for errors. char buf[len]; ssize_t recved; - recved = recv(fd, buf, len, 0); + recved = read(fd, buf, len); + if (recved != 0) // handle error - if (recved < 0) { - /* Handle error. */ - } - - /* Start up / continue the parser. - * Note we pass the recved==0 to http_parser_execute to signal - * that EOF has been recieved. - */ http_parser_execute(parser, buf, recved); if (http_parser_has_error(parser)) { - /* Handle error. Usually just close the connection. */ + // handle error. usually just close the connection } -HTTP needs to know where the end of the stream is. For example, sometimes -servers send responses without Content-Length and expect the client to -consume input (for the body) until EOF. To tell http_parser about EOF, give -`0` as the third parameter to `http_parser_execute()`. Callbacks and errors -can still be encountered during an EOF, so one must still be prepared -to receive them. - Scalar valued message information such as `status_code`, `method`, and the HTTP version are stored in the parser structure. This data is only temporarlly stored in `http_parser` and gets reset on each new message. If this information is needed later, copy it out of the structure during the `headers_complete` callback. - + The parser decodes the transfer-encoding for both requests and responses transparently. That is, a chunked encoding is decoded before being sent to the on_body callback. @@ -143,10 +129,3 @@ Releases * [0.1](http://s3.amazonaws.com/four.livejournal/20090427/http_parser-0.1.tar.gz) The source repo is at [github](http://github.com/ry/http-parser). - -Bindings --------- - - * [Ruby](http://github.com/yakischloba/http-parser-ffi) - - * [Lua](http://github.com/phoenixsol/lua-http-parser) diff --git a/deps/http_parser/http_parser.c b/deps/http_parser/http_parser.c index ecb699c677..b0e4b564e5 100644 --- a/deps/http_parser/http_parser.c +++ b/deps/http_parser/http_parser.c @@ -3,7 +3,7 @@ * Based on Zed Shaw's Mongrel, copyright (c) Zed A. Shaw * * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -11,28 +11,22 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "http_parser.h" #include #include -/* parser->flags */ -#define EATING 0x01 -#define ERROR 0x02 -#define CHUNKED 0x04 -#define EAT_FOREVER 0x10 - static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 @@ -42,14 +36,12 @@ static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }; +#define TRUE 1 +#define FALSE 0 +#define MIN(a,b) (a < b ? a : b) +#define NULL (void*)(0) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -#undef NULL -#define NULL ((void*)(0)) - -#define MAX_FIELD_SIZE (80*1024) +#define MAX_FIELD_SIZE 80*1024 #define REMAINING (unsigned long)(pe - p) #define CALLBACK(FOR) \ @@ -57,36 +49,34 @@ do { \ if (parser->FOR##_mark) { \ parser->FOR##_size += p - parser->FOR##_mark; \ if (parser->FOR##_size > MAX_FIELD_SIZE) { \ - parser->flags |= ERROR; \ - return; \ + parser->error = TRUE; \ + return 0; \ } \ if (parser->on_##FOR) { \ callback_return_value = parser->on_##FOR(parser, \ parser->FOR##_mark, \ p - parser->FOR##_mark); \ } \ - if (callback_return_value != 0) { \ - parser->flags |= ERROR; \ - return; \ - } \ } \ } while(0) #define RESET_PARSER(parser) \ - parser->chunk_size = 0; \ - parser->flags = 0; \ - parser->header_field_mark = NULL; \ - parser->header_value_mark = NULL; \ - parser->query_string_mark = NULL; \ - parser->path_mark = NULL; \ - parser->uri_mark = NULL; \ - parser->fragment_mark = NULL; \ - parser->status_code = 0; \ - parser->method = 0; \ - parser->version = HTTP_VERSION_OTHER; \ - parser->keep_alive = -1; \ - parser->content_length = -1; \ - parser->body_read = 0 + parser->chunk_size = 0; \ + parser->eating = 0; \ + parser->header_field_mark = NULL; \ + parser->header_value_mark = NULL; \ + parser->query_string_mark = NULL; \ + parser->path_mark = NULL; \ + parser->uri_mark = NULL; \ + parser->fragment_mark = NULL; \ + parser->status_code = 0; \ + parser->method = 0; \ + parser->transfer_encoding = HTTP_IDENTITY; \ + parser->version_major = 0; \ + parser->version_minor = 0; \ + parser->keep_alive = -1; \ + parser->content_length = 0; \ + parser->body_read = 0; #define END_REQUEST \ do { \ @@ -108,45 +98,46 @@ do { \ parser->body_read += tmp; \ parser->chunk_size -= tmp; \ if (0 == parser->chunk_size) { \ - parser->flags &= ~EATING; \ - if (!(parser->flags & CHUNKED)) { \ + parser->eating = FALSE; \ + if (parser->transfer_encoding == HTTP_IDENTITY) { \ END_REQUEST; \ } \ } else { \ - parser->flags |= EATING; \ + parser->eating = TRUE; \ } \ } \ } while (0) -#line 411 "http_parser.rl" +#line 413 "http_parser.rl" -#line 126 "http_parser.c" +#line 116 "http_parser.c" static const int http_parser_start = 1; -static const int http_parser_first_final = 280; +static const int http_parser_first_final = 266; static const int http_parser_error = 0; static const int http_parser_en_ChunkedBody = 2; -static const int http_parser_en_ChunkedBody_chunk_chunk_end = 13; -static const int http_parser_en_Requests = 282; -static const int http_parser_en_Responses = 283; +static const int http_parser_en_ChunkedBody_chunk_chunk_end = 12; +static const int http_parser_en_Requests = 268; +static const int http_parser_en_Responses = 269; static const int http_parser_en_main = 1; -#line 414 "http_parser.rl" +#line 416 "http_parser.rl" void -http_parser_init (http_parser *parser, enum http_parser_type type) +http_parser_init (http_parser *parser, enum http_parser_type type) { int cs = 0; -#line 144 "http_parser.c" +#line 134 "http_parser.c" { cs = http_parser_start; } -#line 420 "http_parser.rl" +#line 422 "http_parser.rl" parser->cs = cs; parser->type = type; + parser->error = 0; parser->on_message_begin = NULL; parser->on_path = NULL; @@ -163,39 +154,23 @@ http_parser_init (http_parser *parser, enum http_parser_type type) } /** exec **/ -void +size_t http_parser_execute (http_parser *parser, const char *buffer, size_t len) { size_t tmp; // REMOVE ME this is extremely hacky int callback_return_value = 0; - const char *p, *pe, *eof; + const char *p, *pe; int cs = parser->cs; p = buffer; pe = buffer+len; - eof = len ? NULL : pe; - if (parser->flags & EAT_FOREVER) { - if (len == 0) { - if (parser->on_message_complete) { - callback_return_value = parser->on_message_complete(parser); - if (callback_return_value != 0) parser->flags |= ERROR; - } - } else { - if (parser->on_body) { - callback_return_value = parser->on_body(parser, p, len); - if (callback_return_value != 0) parser->flags |= ERROR; - } - } - return; - } - - if (0 < parser->chunk_size && (parser->flags & EATING)) { + if (0 < parser->chunk_size && parser->eating) { /* eat body */ SKIP_BODY(MIN(len, parser->chunk_size)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } @@ -207,7 +182,7 @@ http_parser_execute (http_parser *parser, const char *buffer, size_t len) if (parser->uri_mark) parser->uri_mark = buffer; -#line 211 "http_parser.c" +#line 186 "http_parser.c" { if ( p == pe ) goto _test_eof; @@ -216,14 +191,14 @@ http_parser_execute (http_parser *parser, const char *buffer, size_t len) _again: switch ( cs ) { case 1: goto st1; - case 280: goto st280; + case 266: goto st266; case 0: goto st0; case 2: goto st2; case 3: goto st3; case 4: goto st4; case 5: goto st5; case 6: goto st6; - case 281: goto st281; + case 267: goto st267; case 7: goto st7; case 8: goto st8; case 9: goto st9; @@ -237,9 +212,9 @@ _again: case 17: goto st17; case 18: goto st18; case 19: goto st19; + case 268: goto st268; case 20: goto st20; case 21: goto st21; - case 282: goto st282; case 22: goto st22; case 23: goto st23; case 24: goto st24; @@ -400,6 +375,7 @@ _again: case 179: goto st179; case 180: goto st180; case 181: goto st181; + case 269: goto st269; case 182: goto st182; case 183: goto st183; case 184: goto st184; @@ -408,7 +384,6 @@ _again: case 187: goto st187; case 188: goto st188; case 189: goto st189; - case 283: goto st283; case 190: goto st190; case 191: goto st191; case 192: goto st192; @@ -485,20 +460,6 @@ _again: case 263: goto st263; case 264: goto st264; case 265: goto st265; - case 266: goto st266; - case 267: goto st267; - case 268: goto st268; - case 269: goto st269; - case 270: goto st270; - case 271: goto st271; - case 272: goto st272; - case 273: goto st273; - case 274: goto st274; - case 275: goto st275; - case 276: goto st276; - case 277: goto st277; - case 278: goto st278; - case 279: goto st279; default: break; } @@ -513,21 +474,21 @@ st1: case 1: goto tr0; tr0: -#line 402 "http_parser.rl" +#line 404 "http_parser.rl" { p--; if (parser->type == HTTP_REQUEST) { - {goto st282;} + {goto st268;} } else { - {goto st283;} + {goto st269;} } } - goto st280; -st280: + goto st266; +st266: if ( ++p == pe ) - goto _test_eof280; -case 280: -#line 531 "http_parser.c" + goto _test_eof266; +case 266: +#line 492 "http_parser.c" goto st0; st0: cs = 0; @@ -548,7 +509,7 @@ case 2: goto tr3; goto st0; tr1: -#line 233 "http_parser.rl" +#line 253 "http_parser.rl" { parser->chunk_size *= 16; parser->chunk_size += unhex[(int)*p]; @@ -558,12 +519,11 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 562 "http_parser.c" +#line 523 "http_parser.c" switch( (*p) ) { case 13: goto st4; - case 32: goto st9; case 48: goto tr1; - case 59: goto st19; + case 59: goto st17; } if ( (*p) < 65 ) { if ( 49 <= (*p) && (*p) <= 57 ) @@ -614,25 +574,25 @@ st6: goto _test_eof6; case 6: if ( (*p) == 10 ) - goto tr10; + goto tr9; goto st0; -tr10: - cs = 281; -#line 253 "http_parser.rl" +tr9: + cs = 267; +#line 273 "http_parser.rl" { END_REQUEST; if (parser->type == HTTP_REQUEST) { - cs = 282; + cs = 268; } else { - cs = 283; + cs = 269; } } goto _again; -st281: +st267: if ( ++p == pe ) - goto _test_eof281; -case 281: -#line 636 "http_parser.c" + goto _test_eof267; +case 267: +#line 596 "http_parser.c" goto st0; st7: if ( ++p == pe ) @@ -669,31 +629,21 @@ case 8: if ( (*p) == 13 ) goto st4; goto st8; -st9: - if ( ++p == pe ) - goto _test_eof9; -case 9: - switch( (*p) ) { - case 13: goto st4; - case 32: goto st9; - } - goto st0; tr3: -#line 233 "http_parser.rl" +#line 253 "http_parser.rl" { parser->chunk_size *= 16; parser->chunk_size += unhex[(int)*p]; } - goto st10; -st10: + goto st9; +st9: if ( ++p == pe ) - goto _test_eof10; -case 10: -#line 693 "http_parser.c" + goto _test_eof9; +case 9: +#line 644 "http_parser.c" switch( (*p) ) { - case 13: goto st11; - case 32: goto st15; - case 59: goto st16; + case 13: goto st10; + case 59: goto st14; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) @@ -704,279 +654,256 @@ case 10: } else goto tr3; goto st0; -st11: +st10: if ( ++p == pe ) - goto _test_eof11; -case 11: + goto _test_eof10; +case 10: if ( (*p) == 10 ) - goto st12; + goto st11; goto st0; -st12: +st11: if ( ++p == pe ) - goto _test_eof12; -case 12: - goto tr16; -tr16: -#line 238 "http_parser.rl" + goto _test_eof11; +case 11: + goto tr14; +tr14: +#line 258 "http_parser.rl" { SKIP_BODY(MIN(parser->chunk_size, REMAINING)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } - p--; + p--; if (parser->chunk_size > REMAINING) { - {p++; cs = 13; goto _out;} + {p++; cs = 12; goto _out;} } else { - {goto st13;} + {goto st12;} } } - goto st13; + goto st12; +st12: + if ( ++p == pe ) + goto _test_eof12; +case 12: +#line 691 "http_parser.c" + if ( (*p) == 13 ) + goto st13; + goto st0; st13: if ( ++p == pe ) goto _test_eof13; case 13: -#line 741 "http_parser.c" - if ( (*p) == 13 ) - goto st14; + if ( (*p) == 10 ) + goto st2; goto st0; st14: if ( ++p == pe ) goto _test_eof14; case 14: - if ( (*p) == 10 ) - goto st2; - goto st0; -st15: - if ( ++p == pe ) - goto _test_eof15; -case 15: - switch( (*p) ) { - case 13: goto st11; - case 32: goto st15; - } - goto st0; -st16: - if ( ++p == pe ) - goto _test_eof16; -case 16: switch( (*p) ) { - case 13: goto st11; - case 32: goto st16; - case 33: goto st17; - case 59: goto st16; - case 61: goto st18; - case 124: goto st17; - case 126: goto st17; + case 13: goto st10; + case 32: goto st14; + case 33: goto st15; + case 59: goto st14; + case 61: goto st16; + case 124: goto st15; + case 126: goto st15; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st17; + goto st15; } else if ( (*p) >= 35 ) - goto st17; + goto st15; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st17; + goto st15; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st17; + goto st15; } else - goto st17; + goto st15; } else - goto st17; + goto st15; goto st0; -st17: +st15: if ( ++p == pe ) - goto _test_eof17; -case 17: + goto _test_eof15; +case 15: switch( (*p) ) { - case 13: goto st11; - case 33: goto st17; - case 59: goto st16; - case 61: goto st18; - case 124: goto st17; - case 126: goto st17; + case 13: goto st10; + case 33: goto st15; + case 59: goto st14; + case 61: goto st16; + case 124: goto st15; + case 126: goto st15; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st17; + goto st15; } else if ( (*p) >= 35 ) - goto st17; + goto st15; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st17; + goto st15; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st17; + goto st15; } else - goto st17; + goto st15; } else - goto st17; + goto st15; goto st0; -st18: +st16: if ( ++p == pe ) - goto _test_eof18; -case 18: + goto _test_eof16; +case 16: switch( (*p) ) { - case 13: goto st11; - case 33: goto st18; - case 59: goto st16; - case 124: goto st18; - case 126: goto st18; + case 13: goto st10; + case 33: goto st16; + case 59: goto st14; + case 124: goto st16; + case 126: goto st16; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st18; + goto st16; } else if ( (*p) >= 35 ) - goto st18; + goto st16; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st18; + goto st16; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st18; + goto st16; } else - goto st18; + goto st16; } else - goto st18; + goto st16; goto st0; -st19: +st17: if ( ++p == pe ) - goto _test_eof19; -case 19: + goto _test_eof17; +case 17: switch( (*p) ) { case 13: goto st4; - case 32: goto st19; - case 33: goto st20; - case 59: goto st19; - case 61: goto st21; - case 124: goto st20; - case 126: goto st20; + case 32: goto st17; + case 33: goto st18; + case 59: goto st17; + case 61: goto st19; + case 124: goto st18; + case 126: goto st18; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st20; + goto st18; } else if ( (*p) >= 35 ) - goto st20; + goto st18; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st20; + goto st18; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st20; + goto st18; } else - goto st20; + goto st18; } else - goto st20; + goto st18; goto st0; -st20: +st18: if ( ++p == pe ) - goto _test_eof20; -case 20: + goto _test_eof18; +case 18: switch( (*p) ) { case 13: goto st4; - case 33: goto st20; - case 59: goto st19; - case 61: goto st21; - case 124: goto st20; - case 126: goto st20; + case 33: goto st18; + case 59: goto st17; + case 61: goto st19; + case 124: goto st18; + case 126: goto st18; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st20; + goto st18; } else if ( (*p) >= 35 ) - goto st20; + goto st18; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st20; + goto st18; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st20; + goto st18; } else - goto st20; + goto st18; } else - goto st20; + goto st18; goto st0; -st21: +st19: if ( ++p == pe ) - goto _test_eof21; -case 21: + goto _test_eof19; +case 19: switch( (*p) ) { case 13: goto st4; - case 33: goto st21; - case 59: goto st19; - case 124: goto st21; - case 126: goto st21; + case 33: goto st19; + case 59: goto st17; + case 124: goto st19; + case 126: goto st19; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st21; + goto st19; } else if ( (*p) >= 35 ) - goto st21; + goto st19; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st21; + goto st19; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st21; + goto st19; } else - goto st21; + goto st19; } else - goto st21; + goto st19; goto st0; -tr50: - cs = 282; -#line 189 "http_parser.rl" +tr45: + cs = 268; +#line 203 "http_parser.rl" { if(parser->on_headers_complete) { callback_return_value = parser->on_headers_complete(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } -#line 262 "http_parser.rl" +#line 282 "http_parser.rl" { - if (parser->flags & CHUNKED) { + if (parser->transfer_encoding == HTTP_CHUNKED) { cs = 2; } else { - /* this is pretty stupid. i'd prefer to combine this with - * skip_chunk_data */ - if (parser->content_length < 0) { - /* If we didn't get a content length; if not keep-alive - * just read body until EOF */ - if (!http_parser_should_keep_alive(parser)) { - parser->flags |= EAT_FOREVER; - parser->chunk_size = REMAINING; - } else { - /* Otherwise, if keep-alive, then assume the message - * has no body. */ - parser->chunk_size = parser->content_length = 0; - } - } else { - parser->chunk_size = parser->content_length; - } - p += 1; + /* this is pretty stupid. i'd prefer to combine this with skip_chunk_data */ + parser->chunk_size = parser->content_length; + p += 1; - SKIP_BODY(MIN(REMAINING, parser->chunk_size)); + SKIP_BODY(MIN(REMAINING, parser->content_length)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } p--; @@ -986,2438 +913,2571 @@ tr50: } } goto _again; -st282: - if ( ++p == pe ) - goto _test_eof282; -case 282: -#line 994 "http_parser.c" - switch( (*p) ) { - case 67: goto tr330; - case 68: goto tr331; - case 71: goto tr332; - case 72: goto tr333; - case 76: goto tr334; - case 77: goto tr335; - case 79: goto tr336; - case 80: goto tr337; - case 84: goto tr338; - case 85: goto tr339; - } - goto st0; -tr330: -#line 199 "http_parser.rl" +st268: + if ( ++p == pe ) + goto _test_eof268; +case 268: +#line 921 "http_parser.c" + switch( (*p) ) { + case 67: goto tr310; + case 68: goto tr311; + case 71: goto tr312; + case 72: goto tr313; + case 76: goto tr314; + case 77: goto tr315; + case 79: goto tr316; + case 80: goto tr317; + case 84: goto tr318; + case 85: goto tr319; + } + goto st0; +tr310: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } - goto st22; -st22: + goto st20; +st20: if ( ++p == pe ) - goto _test_eof22; -case 22: -#line 1024 "http_parser.c" + goto _test_eof20; +case 20: +#line 951 "http_parser.c" if ( (*p) == 79 ) - goto st23; + goto st21; goto st0; -st23: +st21: if ( ++p == pe ) - goto _test_eof23; -case 23: + goto _test_eof21; +case 21: if ( (*p) == 80 ) - goto st24; + goto st22; goto st0; -st24: +st22: if ( ++p == pe ) - goto _test_eof24; -case 24: + goto _test_eof22; +case 22: if ( (*p) == 89 ) - goto st25; + goto st23; goto st0; -st25: +st23: if ( ++p == pe ) - goto _test_eof25; -case 25: + goto _test_eof23; +case 23: if ( (*p) == 32 ) - goto tr26; + goto tr24; goto st0; -tr26: -#line 323 "http_parser.rl" +tr24: +#line 329 "http_parser.rl" { parser->method = HTTP_COPY; } - goto st26; -tr165: -#line 324 "http_parser.rl" + goto st24; +tr154: +#line 330 "http_parser.rl" { parser->method = HTTP_DELETE; } - goto st26; -tr168: -#line 325 "http_parser.rl" + goto st24; +tr157: +#line 331 "http_parser.rl" { parser->method = HTTP_GET; } - goto st26; -tr172: -#line 326 "http_parser.rl" + goto st24; +tr161: +#line 332 "http_parser.rl" { parser->method = HTTP_HEAD; } - goto st26; -tr176: -#line 327 "http_parser.rl" + goto st24; +tr165: +#line 333 "http_parser.rl" { parser->method = HTTP_LOCK; } - goto st26; -tr182: -#line 328 "http_parser.rl" + goto st24; +tr171: +#line 334 "http_parser.rl" { parser->method = HTTP_MKCOL; } - goto st26; -tr185: -#line 329 "http_parser.rl" + goto st24; +tr174: +#line 335 "http_parser.rl" { parser->method = HTTP_MOVE; } - goto st26; -tr192: -#line 330 "http_parser.rl" + goto st24; +tr181: +#line 336 "http_parser.rl" { parser->method = HTTP_OPTIONS; } - goto st26; -tr198: -#line 331 "http_parser.rl" + goto st24; +tr187: +#line 337 "http_parser.rl" { parser->method = HTTP_POST; } - goto st26; -tr206: -#line 332 "http_parser.rl" + goto st24; +tr195: +#line 338 "http_parser.rl" { parser->method = HTTP_PROPFIND; } - goto st26; -tr211: -#line 333 "http_parser.rl" + goto st24; +tr200: +#line 339 "http_parser.rl" { parser->method = HTTP_PROPPATCH; } - goto st26; -tr213: -#line 334 "http_parser.rl" + goto st24; +tr202: +#line 340 "http_parser.rl" { parser->method = HTTP_PUT; } - goto st26; -tr218: -#line 335 "http_parser.rl" + goto st24; +tr207: +#line 341 "http_parser.rl" { parser->method = HTTP_TRACE; } - goto st26; -tr224: -#line 336 "http_parser.rl" + goto st24; +tr213: +#line 342 "http_parser.rl" { parser->method = HTTP_UNLOCK; } - goto st26; -st26: + goto st24; +st24: if ( ++p == pe ) - goto _test_eof26; -case 26: -#line 1109 "http_parser.c" + goto _test_eof24; +case 24: +#line 1036 "http_parser.c" switch( (*p) ) { - case 42: goto tr27; - case 43: goto tr28; - case 47: goto tr29; - case 58: goto tr30; + case 42: goto tr25; + case 43: goto tr26; + case 47: goto tr27; + case 58: goto tr28; } if ( (*p) < 65 ) { if ( 45 <= (*p) && (*p) <= 57 ) - goto tr28; + goto tr26; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) - goto tr28; + goto tr26; } else - goto tr28; + goto tr26; goto st0; -tr27: -#line 148 "http_parser.rl" +tr25: +#line 138 "http_parser.rl" { parser->uri_mark = p; parser->uri_size = 0; } - goto st27; -st27: + goto st25; +st25: if ( ++p == pe ) - goto _test_eof27; -case 27: -#line 1136 "http_parser.c" + goto _test_eof25; +case 25: +#line 1063 "http_parser.c" switch( (*p) ) { - case 32: goto tr31; - case 35: goto tr32; + case 32: goto tr29; + case 35: goto tr30; } goto st0; -tr31: -#line 165 "http_parser.rl" - { +tr29: +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st28; -tr135: -#line 133 "http_parser.rl" + goto st26; +tr124: +#line 123 "http_parser.rl" { parser->fragment_mark = p; parser->fragment_size = 0; } -#line 171 "http_parser.rl" - { +#line 173 "http_parser.rl" + { CALLBACK(fragment); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->fragment_mark = NULL; parser->fragment_size = 0; } - goto st28; -tr138: -#line 171 "http_parser.rl" - { + goto st26; +tr127: +#line 173 "http_parser.rl" + { CALLBACK(fragment); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->fragment_mark = NULL; parser->fragment_size = 0; } - goto st28; -tr146: -#line 183 "http_parser.rl" + goto st26; +tr135: +#line 193 "http_parser.rl" { CALLBACK(path); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->path_mark = NULL; parser->path_size = 0; } -#line 165 "http_parser.rl" - { +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st28; -tr152: -#line 138 "http_parser.rl" + goto st26; +tr141: +#line 128 "http_parser.rl" { parser->query_string_mark = p; parser->query_string_size = 0; } -#line 177 "http_parser.rl" - { +#line 183 "http_parser.rl" + { CALLBACK(query_string); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->query_string_mark = NULL; parser->query_string_size = 0; } -#line 165 "http_parser.rl" - { +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st28; -tr156: -#line 177 "http_parser.rl" - { + goto st26; +tr145: +#line 183 "http_parser.rl" + { CALLBACK(query_string); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->query_string_mark = NULL; parser->query_string_size = 0; } -#line 165 "http_parser.rl" - { +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st28; + goto st26; +st26: + if ( ++p == pe ) + goto _test_eof26; +case 26: +#line 1185 "http_parser.c" + if ( (*p) == 72 ) + goto st27; + goto st0; +st27: + if ( ++p == pe ) + goto _test_eof27; +case 27: + if ( (*p) == 84 ) + goto st28; + goto st0; st28: if ( ++p == pe ) goto _test_eof28; case 28: -#line 1222 "http_parser.c" - if ( (*p) == 72 ) + if ( (*p) == 84 ) goto st29; goto st0; st29: if ( ++p == pe ) goto _test_eof29; case 29: - if ( (*p) == 84 ) + if ( (*p) == 80 ) goto st30; goto st0; st30: if ( ++p == pe ) goto _test_eof30; case 30: - if ( (*p) == 84 ) + if ( (*p) == 47 ) goto st31; goto st0; st31: if ( ++p == pe ) goto _test_eof31; case 31: - if ( (*p) == 80 ) - goto st32; + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr36; goto st0; +tr36: +#line 243 "http_parser.rl" + { + parser->version_major *= 10; + parser->version_major += *p - '0'; + } + goto st32; st32: if ( ++p == pe ) goto _test_eof32; case 32: - if ( (*p) == 47 ) +#line 1235 "http_parser.c" + if ( (*p) == 46 ) goto st33; goto st0; st33: if ( ++p == pe ) goto _test_eof33; case 33: - switch( (*p) ) { - case 48: goto st34; - case 49: goto st108; - } - if ( 50 <= (*p) && (*p) <= 57 ) - goto st112; + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr38; goto st0; +tr38: +#line 248 "http_parser.rl" + { + parser->version_minor *= 10; + parser->version_minor += *p - '0'; + } + goto st34; st34: if ( ++p == pe ) goto _test_eof34; case 34: - if ( (*p) == 46 ) - goto st35; - goto st0; -st35: - if ( ++p == pe ) - goto _test_eof35; -case 35: - if ( (*p) == 57 ) - goto st107; - if ( 48 <= (*p) && (*p) <= 56 ) - goto st36; - goto st0; -st36: - if ( ++p == pe ) - goto _test_eof36; -case 36: +#line 1257 "http_parser.c" if ( (*p) == 13 ) - goto st37; + goto st35; goto st0; -tr54: -#line 128 "http_parser.rl" +tr49: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } -#line 159 "http_parser.rl" +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st37; -tr57: -#line 159 "http_parser.rl" + goto st35; +tr52: +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st37; -tr76: -#line 227 "http_parser.rl" - { parser->keep_alive = 0; } -#line 159 "http_parser.rl" + goto st35; +tr71: +#line 241 "http_parser.rl" + { parser->keep_alive = FALSE; } +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st37; -tr86: -#line 226 "http_parser.rl" - { parser->keep_alive = 1; } -#line 159 "http_parser.rl" + goto st35; +tr81: +#line 240 "http_parser.rl" + { parser->keep_alive = TRUE; } +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st37; -tr126: -#line 224 "http_parser.rl" - { parser->flags |= CHUNKED; } -#line 159 "http_parser.rl" + goto st35; +tr122: +#line 237 "http_parser.rl" + { parser->transfer_encoding = HTTP_IDENTITY; } +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st37; -tr127: -#line 231 "http_parser.rl" - { parser->version = HTTP_VERSION_09; } - goto st37; -tr131: -#line 230 "http_parser.rl" - { parser->version = HTTP_VERSION_10; } - goto st37; -tr132: -#line 229 "http_parser.rl" - { parser->version = HTTP_VERSION_11; } - goto st37; -st37: + goto st35; +st35: if ( ++p == pe ) - goto _test_eof37; -case 37: -#line 1355 "http_parser.c" + goto _test_eof35; +case 35: +#line 1336 "http_parser.c" if ( (*p) == 10 ) - goto st38; + goto st36; goto st0; -st38: +st36: if ( ++p == pe ) - goto _test_eof38; -case 38: + goto _test_eof36; +case 36: switch( (*p) ) { - case 13: goto st39; - case 33: goto tr47; - case 67: goto tr48; - case 84: goto tr49; - case 99: goto tr48; - case 116: goto tr49; - case 124: goto tr47; - case 126: goto tr47; + case 13: goto st37; + case 33: goto tr42; + case 67: goto tr43; + case 84: goto tr44; + case 99: goto tr43; + case 116: goto tr44; + case 124: goto tr42; + case 126: goto tr42; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto tr47; + goto tr42; } else if ( (*p) >= 35 ) - goto tr47; + goto tr42; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto tr47; + goto tr42; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto tr47; + goto tr42; } else - goto tr47; + goto tr42; } else - goto tr47; + goto tr42; goto st0; -st39: +st37: if ( ++p == pe ) - goto _test_eof39; -case 39: + goto _test_eof37; +case 37: if ( (*p) == 10 ) - goto tr50; + goto tr45; goto st0; -tr47: -#line 123 "http_parser.rl" +tr42: +#line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st40; -st40: + goto st38; +st38: if ( ++p == pe ) - goto _test_eof40; -case 40: -#line 1409 "http_parser.c" + goto _test_eof38; +case 38: +#line 1390 "http_parser.c" switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -tr52: -#line 153 "http_parser.rl" +tr47: +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st41; -st41: + goto st39; +st39: if ( ++p == pe ) - goto _test_eof41; -case 41: -#line 1446 "http_parser.c" + goto _test_eof39; +case 39: +#line 1431 "http_parser.c" switch( (*p) ) { - case 13: goto tr54; - case 32: goto st41; + case 13: goto tr49; + case 32: goto st39; } - goto tr53; -tr53: -#line 128 "http_parser.rl" + goto tr48; +tr48: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st42; -st42: + goto st40; +st40: if ( ++p == pe ) - goto _test_eof42; -case 42: -#line 1463 "http_parser.c" + goto _test_eof40; +case 40: +#line 1448 "http_parser.c" if ( (*p) == 13 ) - goto tr57; - goto st42; -tr48: -#line 123 "http_parser.rl" + goto tr52; + goto st40; +tr43: +#line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st43; -st43: + goto st41; +st41: if ( ++p == pe ) - goto _test_eof43; -case 43: -#line 1478 "http_parser.c" + goto _test_eof41; +case 41: +#line 1463 "http_parser.c" switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 79: goto st44; - case 111: goto st44; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 79: goto st42; + case 111: goto st42; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st44: +st42: if ( ++p == pe ) - goto _test_eof44; -case 44: + goto _test_eof42; +case 42: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st45; - case 110: goto st45; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st43; + case 110: goto st43; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st45: +st43: if ( ++p == pe ) - goto _test_eof45; -case 45: + goto _test_eof43; +case 43: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st46; - case 84: goto st69; - case 110: goto st46; - case 116: goto st69; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st44; + case 84: goto st67; + case 110: goto st44; + case 116: goto st67; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st46: +st44: if ( ++p == pe ) - goto _test_eof46; -case 46: + goto _test_eof44; +case 44: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 69: goto st47; - case 101: goto st47; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 69: goto st45; + case 101: goto st45; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st47: +st45: if ( ++p == pe ) - goto _test_eof47; -case 47: + goto _test_eof45; +case 45: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 67: goto st48; - case 99: goto st48; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 67: goto st46; + case 99: goto st46; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st48: +st46: if ( ++p == pe ) - goto _test_eof48; -case 48: + goto _test_eof46; +case 46: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 84: goto st49; - case 116: goto st49; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 84: goto st47; + case 116: goto st47; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st49: +st47: if ( ++p == pe ) - goto _test_eof49; -case 49: + goto _test_eof47; +case 47: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 73: goto st50; - case 105: goto st50; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 73: goto st48; + case 105: goto st48; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st50: +st48: if ( ++p == pe ) - goto _test_eof50; -case 50: + goto _test_eof48; +case 48: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 79: goto st51; - case 111: goto st51; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 79: goto st49; + case 111: goto st49; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st51: +st49: if ( ++p == pe ) - goto _test_eof51; -case 51: + goto _test_eof49; +case 49: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st52; - case 110: goto st52; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st50; + case 110: goto st50; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st52: +st50: if ( ++p == pe ) - goto _test_eof52; -case 52: + goto _test_eof50; +case 50: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr68; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr63; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -tr68: -#line 153 "http_parser.rl" +tr63: +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st53; + goto st51; +st51: + if ( ++p == pe ) + goto _test_eof51; +case 51: +#line 1776 "http_parser.c" + switch( (*p) ) { + case 13: goto tr49; + case 32: goto st51; + case 67: goto tr65; + case 75: goto tr66; + case 99: goto tr65; + case 107: goto tr66; + } + goto tr48; +tr65: +#line 118 "http_parser.rl" + { + parser->header_value_mark = p; + parser->header_value_size = 0; + } + goto st52; +st52: + if ( ++p == pe ) + goto _test_eof52; +case 52: +#line 1797 "http_parser.c" + switch( (*p) ) { + case 13: goto tr52; + case 76: goto st53; + case 108: goto st53; + } + goto st40; st53: if ( ++p == pe ) goto _test_eof53; case 53: -#line 1787 "http_parser.c" switch( (*p) ) { - case 13: goto tr54; - case 32: goto st53; - case 67: goto tr70; - case 75: goto tr71; - case 99: goto tr70; - case 107: goto tr71; + case 13: goto tr52; + case 79: goto st54; + case 111: goto st54; } - goto tr53; -tr70: -#line 128 "http_parser.rl" - { - parser->header_value_mark = p; - parser->header_value_size = 0; - } - goto st54; + goto st40; st54: if ( ++p == pe ) goto _test_eof54; case 54: -#line 1808 "http_parser.c" switch( (*p) ) { - case 13: goto tr57; - case 76: goto st55; - case 108: goto st55; + case 13: goto tr52; + case 83: goto st55; + case 115: goto st55; } - goto st42; + goto st40; st55: if ( ++p == pe ) goto _test_eof55; case 55: switch( (*p) ) { - case 13: goto tr57; - case 79: goto st56; - case 111: goto st56; + case 13: goto tr52; + case 69: goto st56; + case 101: goto st56; } - goto st42; + goto st40; st56: if ( ++p == pe ) goto _test_eof56; case 56: - switch( (*p) ) { - case 13: goto tr57; - case 83: goto st57; - case 115: goto st57; - } - goto st42; + if ( (*p) == 13 ) + goto tr71; + goto st40; +tr66: +#line 118 "http_parser.rl" + { + parser->header_value_mark = p; + parser->header_value_size = 0; + } + goto st57; st57: if ( ++p == pe ) goto _test_eof57; case 57: +#line 1852 "http_parser.c" switch( (*p) ) { - case 13: goto tr57; + case 13: goto tr52; case 69: goto st58; case 101: goto st58; } - goto st42; + goto st40; st58: if ( ++p == pe ) goto _test_eof58; case 58: - if ( (*p) == 13 ) - goto tr76; - goto st42; -tr71: -#line 128 "http_parser.rl" - { - parser->header_value_mark = p; - parser->header_value_size = 0; - } - goto st59; + switch( (*p) ) { + case 13: goto tr52; + case 69: goto st59; + case 101: goto st59; + } + goto st40; st59: if ( ++p == pe ) goto _test_eof59; case 59: -#line 1863 "http_parser.c" switch( (*p) ) { - case 13: goto tr57; - case 69: goto st60; - case 101: goto st60; + case 13: goto tr52; + case 80: goto st60; + case 112: goto st60; } - goto st42; + goto st40; st60: if ( ++p == pe ) goto _test_eof60; case 60: switch( (*p) ) { - case 13: goto tr57; - case 69: goto st61; - case 101: goto st61; + case 13: goto tr52; + case 45: goto st61; } - goto st42; + goto st40; st61: if ( ++p == pe ) goto _test_eof61; case 61: switch( (*p) ) { - case 13: goto tr57; - case 80: goto st62; - case 112: goto st62; + case 13: goto tr52; + case 65: goto st62; + case 97: goto st62; } - goto st42; + goto st40; st62: if ( ++p == pe ) goto _test_eof62; case 62: switch( (*p) ) { - case 13: goto tr57; - case 45: goto st63; + case 13: goto tr52; + case 76: goto st63; + case 108: goto st63; } - goto st42; + goto st40; st63: if ( ++p == pe ) goto _test_eof63; case 63: switch( (*p) ) { - case 13: goto tr57; - case 65: goto st64; - case 97: goto st64; + case 13: goto tr52; + case 73: goto st64; + case 105: goto st64; } - goto st42; + goto st40; st64: if ( ++p == pe ) goto _test_eof64; case 64: switch( (*p) ) { - case 13: goto tr57; - case 76: goto st65; - case 108: goto st65; + case 13: goto tr52; + case 86: goto st65; + case 118: goto st65; } - goto st42; + goto st40; st65: if ( ++p == pe ) goto _test_eof65; case 65: switch( (*p) ) { - case 13: goto tr57; - case 73: goto st66; - case 105: goto st66; + case 13: goto tr52; + case 69: goto st66; + case 101: goto st66; } - goto st42; + goto st40; st66: if ( ++p == pe ) goto _test_eof66; case 66: - switch( (*p) ) { - case 13: goto tr57; - case 86: goto st67; - case 118: goto st67; - } - goto st42; + if ( (*p) == 13 ) + goto tr81; + goto st40; st67: if ( ++p == pe ) goto _test_eof67; case 67: switch( (*p) ) { - case 13: goto tr57; + case 33: goto st38; + case 58: goto tr47; case 69: goto st68; case 101: goto st68; - } - goto st42; -st68: - if ( ++p == pe ) - goto _test_eof68; -case 68: - if ( (*p) == 13 ) - goto tr86; - goto st42; -st69: - if ( ++p == pe ) - goto _test_eof69; -case 69: - switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 69: goto st70; - case 101: goto st70; - case 124: goto st40; - case 126: goto st40; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st70: +st68: if ( ++p == pe ) - goto _test_eof70; -case 70: + goto _test_eof68; +case 68: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st71; - case 110: goto st71; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st69; + case 110: goto st69; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st71: +st69: if ( ++p == pe ) - goto _test_eof71; -case 71: + goto _test_eof69; +case 69: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 84: goto st72; - case 116: goto st72; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 84: goto st70; + case 116: goto st70; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st72: +st70: if ( ++p == pe ) - goto _test_eof72; -case 72: + goto _test_eof70; +case 70: switch( (*p) ) { - case 33: goto st40; - case 45: goto st73; - case 46: goto st40; - case 58: goto tr52; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 45: goto st71; + case 46: goto st38; + case 58: goto tr47; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 48 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else if ( (*p) >= 65 ) - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st73: +st71: if ( ++p == pe ) - goto _test_eof73; -case 73: + goto _test_eof71; +case 71: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 76: goto st74; - case 108: goto st74; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 76: goto st72; + case 108: goto st72; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st74: +st72: if ( ++p == pe ) - goto _test_eof74; -case 74: + goto _test_eof72; +case 72: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 69: goto st75; - case 101: goto st75; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 69: goto st73; + case 101: goto st73; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st75: +st73: if ( ++p == pe ) - goto _test_eof75; -case 75: + goto _test_eof73; +case 73: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st76; - case 110: goto st76; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st74; + case 110: goto st74; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st76: +st74: if ( ++p == pe ) - goto _test_eof76; -case 76: + goto _test_eof74; +case 74: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 71: goto st77; - case 103: goto st77; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 71: goto st75; + case 103: goto st75; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st77: +st75: if ( ++p == pe ) - goto _test_eof77; -case 77: + goto _test_eof75; +case 75: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 84: goto st78; - case 116: goto st78; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 84: goto st76; + case 116: goto st76; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st78: +st76: if ( ++p == pe ) - goto _test_eof78; -case 78: + goto _test_eof76; +case 76: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 72: goto st79; - case 104: goto st79; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 72: goto st77; + case 104: goto st77; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -st79: +st77: if ( ++p == pe ) - goto _test_eof79; -case 79: + goto _test_eof77; +case 77: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr97; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr92; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; -tr97: -#line 153 "http_parser.rl" +tr92: +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st80; -st80: + goto st78; +st78: if ( ++p == pe ) - goto _test_eof80; -case 80: -#line 2293 "http_parser.c" + goto _test_eof78; +case 78: +#line 2286 "http_parser.c" switch( (*p) ) { - case 13: goto tr54; - case 32: goto st80; + case 13: goto tr49; + case 32: goto st78; } if ( 48 <= (*p) && (*p) <= 57 ) - goto tr99; - goto tr53; -tr99: -#line 209 "http_parser.rl" + goto tr94; + goto tr48; +tr94: +#line 223 "http_parser.rl" { - if (parser->content_length == -1) parser->content_length = 0; if (parser->content_length > INT_MAX) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } parser->content_length *= 10; parser->content_length += *p - '0'; } -#line 128 "http_parser.rl" +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st81; -tr100: -#line 209 "http_parser.rl" + goto st79; +tr95: +#line 223 "http_parser.rl" { - if (parser->content_length == -1) parser->content_length = 0; if (parser->content_length > INT_MAX) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } parser->content_length *= 10; parser->content_length += *p - '0'; } - goto st81; -st81: + goto st79; +st79: if ( ++p == pe ) - goto _test_eof81; -case 81: -#line 2334 "http_parser.c" + goto _test_eof79; +case 79: +#line 2325 "http_parser.c" if ( (*p) == 13 ) - goto tr57; + goto tr52; if ( 48 <= (*p) && (*p) <= 57 ) - goto tr100; - goto st42; -tr49: -#line 123 "http_parser.rl" + goto tr95; + goto st40; +tr44: +#line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st82; + goto st80; +st80: + if ( ++p == pe ) + goto _test_eof80; +case 80: +#line 2342 "http_parser.c" + switch( (*p) ) { + case 33: goto st38; + case 58: goto tr47; + case 82: goto st81; + case 114: goto st81; + case 124: goto st38; + case 126: goto st38; + } + if ( (*p) < 45 ) { + if ( (*p) > 39 ) { + if ( 42 <= (*p) && (*p) <= 43 ) + goto st38; + } else if ( (*p) >= 35 ) + goto st38; + } else if ( (*p) > 46 ) { + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st38; + } else if ( (*p) > 90 ) { + if ( 94 <= (*p) && (*p) <= 122 ) + goto st38; + } else + goto st38; + } else + goto st38; + goto st0; +st81: + if ( ++p == pe ) + goto _test_eof81; +case 81: + switch( (*p) ) { + case 33: goto st38; + case 58: goto tr47; + case 65: goto st82; + case 97: goto st82; + case 124: goto st38; + case 126: goto st38; + } + if ( (*p) < 45 ) { + if ( (*p) > 39 ) { + if ( 42 <= (*p) && (*p) <= 43 ) + goto st38; + } else if ( (*p) >= 35 ) + goto st38; + } else if ( (*p) > 46 ) { + if ( (*p) < 66 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st38; + } else if ( (*p) > 90 ) { + if ( 94 <= (*p) && (*p) <= 122 ) + goto st38; + } else + goto st38; + } else + goto st38; + goto st0; st82: if ( ++p == pe ) goto _test_eof82; case 82: -#line 2351 "http_parser.c" switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 82: goto st83; - case 114: goto st83; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st83; + case 110: goto st83; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st83: if ( ++p == pe ) goto _test_eof83; case 83: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 65: goto st84; - case 97: goto st84; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 83: goto st84; + case 115: goto st84; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { - if ( (*p) < 66 ) { + if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st84: if ( ++p == pe ) goto _test_eof84; case 84: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st85; - case 110: goto st85; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 70: goto st85; + case 102: goto st85; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st85: if ( ++p == pe ) goto _test_eof85; case 85: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 83: goto st86; - case 115: goto st86; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 69: goto st86; + case 101: goto st86; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st86: if ( ++p == pe ) goto _test_eof86; case 86: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 70: goto st87; - case 102: goto st87; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 82: goto st87; + case 114: goto st87; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st87: if ( ++p == pe ) goto _test_eof87; case 87: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 69: goto st88; - case 101: goto st88; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 45: goto st88; + case 46: goto st38; + case 58: goto tr47; + case 124: goto st38; + case 126: goto st38; } - if ( (*p) < 45 ) { + if ( (*p) < 48 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; - } else if ( (*p) > 46 ) { - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; - } else if ( (*p) > 90 ) { + goto st38; + } else if ( (*p) > 57 ) { + if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; - } else - goto st40; + goto st38; + } else if ( (*p) >= 65 ) + goto st38; } else - goto st40; + goto st38; goto st0; st88: if ( ++p == pe ) goto _test_eof88; case 88: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 82: goto st89; - case 114: goto st89; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 69: goto st89; + case 101: goto st89; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st89: if ( ++p == pe ) goto _test_eof89; case 89: switch( (*p) ) { - case 33: goto st40; - case 45: goto st90; - case 46: goto st40; - case 58: goto tr52; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st90; + case 110: goto st90; + case 124: goto st38; + case 126: goto st38; } - if ( (*p) < 48 ) { + if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; - } else if ( (*p) > 57 ) { - if ( (*p) > 90 ) { + goto st38; + } else if ( (*p) > 46 ) { + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st38; + } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; - } else if ( (*p) >= 65 ) - goto st40; + goto st38; + } else + goto st38; } else - goto st40; + goto st38; goto st0; st90: if ( ++p == pe ) goto _test_eof90; case 90: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 69: goto st91; - case 101: goto st91; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 67: goto st91; + case 99: goto st91; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st91: if ( ++p == pe ) goto _test_eof91; case 91: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st92; - case 110: goto st92; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 79: goto st92; + case 111: goto st92; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st92: if ( ++p == pe ) goto _test_eof92; case 92: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 67: goto st93; - case 99: goto st93; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 68: goto st93; + case 100: goto st93; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st93: if ( ++p == pe ) goto _test_eof93; case 93: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 79: goto st94; - case 111: goto st94; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 73: goto st94; + case 105: goto st94; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st94: if ( ++p == pe ) goto _test_eof94; case 94: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 68: goto st95; - case 100: goto st95; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 78: goto st95; + case 110: goto st95; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st95: if ( ++p == pe ) goto _test_eof95; case 95: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 73: goto st96; - case 105: goto st96; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr47; + case 71: goto st96; + case 103: goto st96; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; st96: if ( ++p == pe ) goto _test_eof96; case 96: switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 78: goto st97; - case 110: goto st97; - case 124: goto st40; - case 126: goto st40; + case 33: goto st38; + case 58: goto tr112; + case 124: goto st38; + case 126: goto st38; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; + goto st38; } else if ( (*p) >= 35 ) - goto st40; + goto st38; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; + goto st38; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; + goto st38; } else - goto st40; + goto st38; } else - goto st40; + goto st38; goto st0; +tr112: +#line 238 "http_parser.rl" + { parser->transfer_encoding = HTTP_CHUNKED; } +#line 143 "http_parser.rl" + { + CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } + parser->header_field_mark = NULL; + parser->header_field_size = 0; + } + goto st97; st97: if ( ++p == pe ) goto _test_eof97; case 97: +#line 2862 "http_parser.c" switch( (*p) ) { - case 33: goto st40; - case 58: goto tr52; - case 71: goto st98; - case 103: goto st98; - case 124: goto st40; - case 126: goto st40; + case 13: goto tr49; + case 32: goto st97; + case 105: goto tr114; } - if ( (*p) < 45 ) { - if ( (*p) > 39 ) { - if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; - } else if ( (*p) >= 35 ) - goto st40; - } else if ( (*p) > 46 ) { - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; - } else if ( (*p) > 90 ) { - if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; - } else - goto st40; - } else - goto st40; - goto st0; + goto tr48; +tr114: +#line 118 "http_parser.rl" + { + parser->header_value_mark = p; + parser->header_value_size = 0; + } + goto st98; st98: if ( ++p == pe ) goto _test_eof98; case 98: +#line 2880 "http_parser.c" switch( (*p) ) { - case 33: goto st40; - case 58: goto tr117; - case 124: goto st40; - case 126: goto st40; + case 13: goto tr52; + case 100: goto st99; } - if ( (*p) < 45 ) { - if ( (*p) > 39 ) { - if ( 42 <= (*p) && (*p) <= 43 ) - goto st40; - } else if ( (*p) >= 35 ) - goto st40; - } else if ( (*p) > 46 ) { - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st40; - } else if ( (*p) > 90 ) { - if ( 94 <= (*p) && (*p) <= 122 ) - goto st40; - } else - goto st40; - } else - goto st40; - goto st0; -tr117: -#line 153 "http_parser.rl" - { - CALLBACK(header_field); - parser->header_field_mark = NULL; - parser->header_field_size = 0; - } - goto st99; + goto st40; st99: if ( ++p == pe ) goto _test_eof99; case 99: -#line 2865 "http_parser.c" switch( (*p) ) { - case 13: goto tr54; - case 32: goto st99; - case 67: goto tr119; - case 99: goto tr119; + case 13: goto tr52; + case 101: goto st100; } - goto tr53; -tr119: -#line 128 "http_parser.rl" - { - parser->header_value_mark = p; - parser->header_value_size = 0; - } - goto st100; + goto st40; st100: if ( ++p == pe ) goto _test_eof100; case 100: -#line 2884 "http_parser.c" switch( (*p) ) { - case 13: goto tr57; - case 72: goto st101; - case 104: goto st101; + case 13: goto tr52; + case 110: goto st101; } - goto st42; + goto st40; st101: if ( ++p == pe ) goto _test_eof101; case 101: switch( (*p) ) { - case 13: goto tr57; - case 85: goto st102; - case 117: goto st102; + case 13: goto tr52; + case 116: goto st102; } - goto st42; + goto st40; st102: if ( ++p == pe ) goto _test_eof102; case 102: switch( (*p) ) { - case 13: goto tr57; - case 78: goto st103; - case 110: goto st103; + case 13: goto tr52; + case 105: goto st103; } - goto st42; + goto st40; st103: if ( ++p == pe ) goto _test_eof103; case 103: switch( (*p) ) { - case 13: goto tr57; - case 75: goto st104; - case 107: goto st104; + case 13: goto tr52; + case 116: goto st104; } - goto st42; + goto st40; st104: if ( ++p == pe ) goto _test_eof104; case 104: switch( (*p) ) { - case 13: goto tr57; - case 69: goto st105; - case 101: goto st105; + case 13: goto tr52; + case 121: goto st105; } - goto st42; + goto st40; st105: if ( ++p == pe ) goto _test_eof105; case 105: - switch( (*p) ) { - case 13: goto tr57; - case 68: goto st106; - case 100: goto st106; - } - goto st42; -st106: - if ( ++p == pe ) - goto _test_eof106; -case 106: - if ( (*p) == 13 ) - goto tr126; - goto st42; -st107: - if ( ++p == pe ) - goto _test_eof107; -case 107: if ( (*p) == 13 ) - goto tr127; - goto st0; -st108: - if ( ++p == pe ) - goto _test_eof108; -case 108: - if ( (*p) == 46 ) - goto st109; - goto st0; -st109: - if ( ++p == pe ) - goto _test_eof109; -case 109: - switch( (*p) ) { - case 48: goto st110; - case 49: goto st111; - } - if ( 50 <= (*p) && (*p) <= 57 ) - goto st36; - goto st0; -st110: - if ( ++p == pe ) - goto _test_eof110; -case 110: - if ( (*p) == 13 ) - goto tr131; - goto st0; -st111: - if ( ++p == pe ) - goto _test_eof111; -case 111: - if ( (*p) == 13 ) - goto tr132; - goto st0; -st112: - if ( ++p == pe ) - goto _test_eof112; -case 112: - if ( (*p) == 46 ) - goto st113; - goto st0; -st113: - if ( ++p == pe ) - goto _test_eof113; -case 113: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st36; - goto st0; -tr32: -#line 165 "http_parser.rl" - { + goto tr122; + goto st40; +tr30: +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st114; -tr147: -#line 183 "http_parser.rl" + goto st106; +tr136: +#line 193 "http_parser.rl" { CALLBACK(path); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->path_mark = NULL; parser->path_size = 0; } -#line 165 "http_parser.rl" - { +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st114; -tr153: -#line 138 "http_parser.rl" + goto st106; +tr142: +#line 128 "http_parser.rl" { parser->query_string_mark = p; parser->query_string_size = 0; } -#line 177 "http_parser.rl" - { +#line 183 "http_parser.rl" + { CALLBACK(query_string); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->query_string_mark = NULL; parser->query_string_size = 0; } -#line 165 "http_parser.rl" - { +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st114; -tr157: -#line 177 "http_parser.rl" - { + goto st106; +tr146: +#line 183 "http_parser.rl" + { CALLBACK(query_string); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->query_string_mark = NULL; parser->query_string_size = 0; } -#line 165 "http_parser.rl" - { +#line 163 "http_parser.rl" + { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - goto st114; -st114: + goto st106; +st106: if ( ++p == pe ) - goto _test_eof114; -case 114: -#line 3060 "http_parser.c" + goto _test_eof106; +case 106: +#line 3034 "http_parser.c" switch( (*p) ) { - case 32: goto tr135; + case 32: goto tr124; case 35: goto st0; - case 37: goto tr136; + case 37: goto tr125; case 60: goto st0; case 62: goto st0; case 127: goto st0; } if ( 0 <= (*p) && (*p) <= 31 ) goto st0; - goto tr134; -tr134: -#line 133 "http_parser.rl" + goto tr123; +tr123: +#line 123 "http_parser.rl" { parser->fragment_mark = p; parser->fragment_size = 0; } - goto st115; -st115: + goto st107; +st107: if ( ++p == pe ) - goto _test_eof115; -case 115: -#line 3083 "http_parser.c" + goto _test_eof107; +case 107: +#line 3057 "http_parser.c" switch( (*p) ) { - case 32: goto tr138; + case 32: goto tr127; case 35: goto st0; - case 37: goto st116; + case 37: goto st108; case 60: goto st0; case 62: goto st0; case 127: goto st0; } if ( 0 <= (*p) && (*p) <= 31 ) goto st0; - goto st115; -tr136: -#line 133 "http_parser.rl" + goto st107; +tr125: +#line 123 "http_parser.rl" { parser->fragment_mark = p; parser->fragment_size = 0; } - goto st116; -st116: + goto st108; +st108: if ( ++p == pe ) - goto _test_eof116; -case 116: -#line 3106 "http_parser.c" + goto _test_eof108; +case 108: +#line 3080 "http_parser.c" if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st117; + goto st109; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st117; + goto st109; } else - goto st117; + goto st109; goto st0; -st117: +st109: if ( ++p == pe ) - goto _test_eof117; -case 117: + goto _test_eof109; +case 109: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st115; + goto st107; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st115; + goto st107; } else - goto st115; + goto st107; goto st0; -tr28: -#line 148 "http_parser.rl" +tr26: +#line 138 "http_parser.rl" { parser->uri_mark = p; parser->uri_size = 0; } - goto st118; -st118: + goto st110; +st110: if ( ++p == pe ) - goto _test_eof118; -case 118: -#line 3140 "http_parser.c" + goto _test_eof110; +case 110: +#line 3114 "http_parser.c" switch( (*p) ) { - case 43: goto st118; - case 58: goto st119; + case 43: goto st110; + case 58: goto st111; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) - goto st118; + goto st110; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) - goto st118; + goto st110; } else if ( (*p) >= 65 ) - goto st118; + goto st110; } else - goto st118; + goto st110; goto st0; -tr30: -#line 148 "http_parser.rl" +tr28: +#line 138 "http_parser.rl" { parser->uri_mark = p; parser->uri_size = 0; } - goto st119; -st119: + goto st111; +st111: if ( ++p == pe ) - goto _test_eof119; -case 119: -#line 3168 "http_parser.c" + goto _test_eof111; +case 111: +#line 3142 "http_parser.c" switch( (*p) ) { - case 32: goto tr31; - case 35: goto tr32; - case 37: goto st120; + case 32: goto tr29; + case 35: goto tr30; + case 37: goto st112; case 60: goto st0; case 62: goto st0; case 127: goto st0; } if ( 0 <= (*p) && (*p) <= 31 ) goto st0; - goto st119; -st120: + goto st111; +st112: if ( ++p == pe ) - goto _test_eof120; -case 120: + goto _test_eof112; +case 112: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st121; + goto st113; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st121; + goto st113; } else - goto st121; + goto st113; goto st0; -st121: +st113: if ( ++p == pe ) - goto _test_eof121; -case 121: + goto _test_eof113; +case 113: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st119; + goto st111; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st119; + goto st111; } else - goto st119; + goto st111; goto st0; -tr29: -#line 148 "http_parser.rl" +tr27: +#line 138 "http_parser.rl" { parser->uri_mark = p; parser->uri_size = 0; } -#line 143 "http_parser.rl" +#line 133 "http_parser.rl" { parser->path_mark = p; parser->path_size = 0; } - goto st122; -st122: + goto st114; +st114: if ( ++p == pe ) - goto _test_eof122; -case 122: -#line 3222 "http_parser.c" + goto _test_eof114; +case 114: +#line 3196 "http_parser.c" switch( (*p) ) { - case 32: goto tr146; - case 35: goto tr147; - case 37: goto st123; + case 32: goto tr135; + case 35: goto tr136; + case 37: goto st115; case 60: goto st0; case 62: goto st0; - case 63: goto tr149; + case 63: goto tr138; case 127: goto st0; } if ( 0 <= (*p) && (*p) <= 31 ) goto st0; - goto st122; -st123: + goto st114; +st115: if ( ++p == pe ) - goto _test_eof123; -case 123: + goto _test_eof115; +case 115: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st124; + goto st116; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st124; + goto st116; } else - goto st124; + goto st116; goto st0; -st124: +st116: if ( ++p == pe ) - goto _test_eof124; -case 124: + goto _test_eof116; +case 116: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st122; + goto st114; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st122; + goto st114; } else - goto st122; + goto st114; goto st0; -tr149: -#line 183 "http_parser.rl" +tr138: +#line 193 "http_parser.rl" { CALLBACK(path); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->path_mark = NULL; parser->path_size = 0; } - goto st125; -st125: + goto st117; +st117: if ( ++p == pe ) - goto _test_eof125; -case 125: -#line 3273 "http_parser.c" + goto _test_eof117; +case 117: +#line 3251 "http_parser.c" switch( (*p) ) { - case 32: goto tr152; - case 35: goto tr153; - case 37: goto tr154; + case 32: goto tr141; + case 35: goto tr142; + case 37: goto tr143; case 60: goto st0; case 62: goto st0; case 127: goto st0; } if ( 0 <= (*p) && (*p) <= 31 ) goto st0; - goto tr151; -tr151: -#line 138 "http_parser.rl" + goto tr140; +tr140: +#line 128 "http_parser.rl" { parser->query_string_mark = p; parser->query_string_size = 0; } - goto st126; -st126: + goto st118; +st118: if ( ++p == pe ) - goto _test_eof126; -case 126: -#line 3296 "http_parser.c" + goto _test_eof118; +case 118: +#line 3274 "http_parser.c" switch( (*p) ) { - case 32: goto tr156; - case 35: goto tr157; - case 37: goto st127; + case 32: goto tr145; + case 35: goto tr146; + case 37: goto st119; case 60: goto st0; case 62: goto st0; case 127: goto st0; } if ( 0 <= (*p) && (*p) <= 31 ) goto st0; - goto st126; -tr154: -#line 138 "http_parser.rl" + goto st118; +tr143: +#line 128 "http_parser.rl" { parser->query_string_mark = p; parser->query_string_size = 0; } - goto st127; -st127: + goto st119; +st119: if ( ++p == pe ) - goto _test_eof127; -case 127: -#line 3319 "http_parser.c" + goto _test_eof119; +case 119: +#line 3297 "http_parser.c" if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st128; + goto st120; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st128; + goto st120; } else - goto st128; + goto st120; goto st0; -st128: +st120: if ( ++p == pe ) - goto _test_eof128; -case 128: + goto _test_eof120; +case 120: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st126; + goto st118; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) - goto st126; + goto st118; } else - goto st126; + goto st118; goto st0; -tr331: -#line 199 "http_parser.rl" +tr311: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } - goto st129; -st129: + goto st121; +st121: if ( ++p == pe ) - goto _test_eof129; -case 129: -#line 3358 "http_parser.c" + goto _test_eof121; +case 121: +#line 3336 "http_parser.c" if ( (*p) == 69 ) - goto st130; + goto st122; goto st0; -st130: +st122: if ( ++p == pe ) - goto _test_eof130; -case 130: + goto _test_eof122; +case 122: if ( (*p) == 76 ) - goto st131; + goto st123; goto st0; -st131: +st123: if ( ++p == pe ) - goto _test_eof131; -case 131: + goto _test_eof123; +case 123: if ( (*p) == 69 ) - goto st132; + goto st124; goto st0; -st132: +st124: if ( ++p == pe ) - goto _test_eof132; -case 132: + goto _test_eof124; +case 124: if ( (*p) == 84 ) - goto st133; + goto st125; goto st0; -st133: +st125: if ( ++p == pe ) - goto _test_eof133; -case 133: + goto _test_eof125; +case 125: if ( (*p) == 69 ) - goto st134; + goto st126; goto st0; -st134: +st126: if ( ++p == pe ) - goto _test_eof134; -case 134: + goto _test_eof126; +case 126: if ( (*p) == 32 ) - goto tr165; + goto tr154; goto st0; -tr332: -#line 199 "http_parser.rl" +tr312: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } - goto st135; + goto st127; +st127: + if ( ++p == pe ) + goto _test_eof127; +case 127: +#line 3391 "http_parser.c" + if ( (*p) == 69 ) + goto st128; + goto st0; +st128: + if ( ++p == pe ) + goto _test_eof128; +case 128: + if ( (*p) == 84 ) + goto st129; + goto st0; +st129: + if ( ++p == pe ) + goto _test_eof129; +case 129: + if ( (*p) == 32 ) + goto tr157; + goto st0; +tr313: +#line 213 "http_parser.rl" + { + if(parser->on_message_begin) { + callback_return_value = parser->on_message_begin(parser); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } + } + } + goto st130; +st130: + if ( ++p == pe ) + goto _test_eof130; +case 130: +#line 3425 "http_parser.c" + if ( (*p) == 69 ) + goto st131; + goto st0; +st131: + if ( ++p == pe ) + goto _test_eof131; +case 131: + if ( (*p) == 65 ) + goto st132; + goto st0; +st132: + if ( ++p == pe ) + goto _test_eof132; +case 132: + if ( (*p) == 68 ) + goto st133; + goto st0; +st133: + if ( ++p == pe ) + goto _test_eof133; +case 133: + if ( (*p) == 32 ) + goto tr161; + goto st0; +tr314: +#line 213 "http_parser.rl" + { + if(parser->on_message_begin) { + callback_return_value = parser->on_message_begin(parser); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } + } + } + goto st134; +st134: + if ( ++p == pe ) + goto _test_eof134; +case 134: +#line 3466 "http_parser.c" + if ( (*p) == 79 ) + goto st135; + goto st0; st135: if ( ++p == pe ) goto _test_eof135; case 135: -#line 3413 "http_parser.c" - if ( (*p) == 69 ) + if ( (*p) == 67 ) goto st136; goto st0; st136: if ( ++p == pe ) goto _test_eof136; case 136: - if ( (*p) == 84 ) + if ( (*p) == 75 ) goto st137; goto st0; st137: @@ -3425,16 +3485,16 @@ st137: goto _test_eof137; case 137: if ( (*p) == 32 ) - goto tr168; + goto tr165; goto st0; -tr333: -#line 199 "http_parser.rl" +tr315: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } @@ -3443,63 +3503,52 @@ st138: if ( ++p == pe ) goto _test_eof138; case 138: -#line 3447 "http_parser.c" - if ( (*p) == 69 ) - goto st139; +#line 3507 "http_parser.c" + switch( (*p) ) { + case 75: goto st139; + case 79: goto st143; + } goto st0; st139: if ( ++p == pe ) goto _test_eof139; case 139: - if ( (*p) == 65 ) + if ( (*p) == 67 ) goto st140; goto st0; st140: if ( ++p == pe ) goto _test_eof140; case 140: - if ( (*p) == 68 ) + if ( (*p) == 79 ) goto st141; goto st0; st141: if ( ++p == pe ) goto _test_eof141; case 141: - if ( (*p) == 32 ) - goto tr172; + if ( (*p) == 76 ) + goto st142; goto st0; -tr334: -#line 199 "http_parser.rl" - { - if(parser->on_message_begin) { - callback_return_value = parser->on_message_begin(parser); - if (callback_return_value != 0) { - parser->flags |= ERROR; - return; - } - } - } - goto st142; st142: if ( ++p == pe ) goto _test_eof142; case 142: -#line 3488 "http_parser.c" - if ( (*p) == 79 ) - goto st143; + if ( (*p) == 32 ) + goto tr171; goto st0; st143: if ( ++p == pe ) goto _test_eof143; case 143: - if ( (*p) == 67 ) + if ( (*p) == 86 ) goto st144; goto st0; st144: if ( ++p == pe ) goto _test_eof144; case 144: - if ( (*p) == 75 ) + if ( (*p) == 69 ) goto st145; goto st0; st145: @@ -3507,16 +3556,16 @@ st145: goto _test_eof145; case 145: if ( (*p) == 32 ) - goto tr176; + goto tr174; goto st0; -tr335: -#line 199 "http_parser.rl" +tr316: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } @@ -3525,79 +3574,80 @@ st146: if ( ++p == pe ) goto _test_eof146; case 146: -#line 3529 "http_parser.c" - switch( (*p) ) { - case 75: goto st147; - case 79: goto st151; - } +#line 3578 "http_parser.c" + if ( (*p) == 80 ) + goto st147; goto st0; st147: if ( ++p == pe ) goto _test_eof147; case 147: - if ( (*p) == 67 ) + if ( (*p) == 84 ) goto st148; goto st0; st148: if ( ++p == pe ) goto _test_eof148; case 148: - if ( (*p) == 79 ) + if ( (*p) == 73 ) goto st149; goto st0; st149: if ( ++p == pe ) goto _test_eof149; case 149: - if ( (*p) == 76 ) + if ( (*p) == 79 ) goto st150; goto st0; st150: if ( ++p == pe ) goto _test_eof150; case 150: - if ( (*p) == 32 ) - goto tr182; + if ( (*p) == 78 ) + goto st151; goto st0; st151: if ( ++p == pe ) goto _test_eof151; case 151: - if ( (*p) == 86 ) + if ( (*p) == 83 ) goto st152; goto st0; st152: if ( ++p == pe ) goto _test_eof152; case 152: - if ( (*p) == 69 ) - goto st153; - goto st0; -st153: - if ( ++p == pe ) - goto _test_eof153; -case 153: if ( (*p) == 32 ) - goto tr185; + goto tr181; goto st0; -tr336: -#line 199 "http_parser.rl" +tr317: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } - goto st154; + goto st153; +st153: + if ( ++p == pe ) + goto _test_eof153; +case 153: +#line 3640 "http_parser.c" + switch( (*p) ) { + case 79: goto st154; + case 82: goto st157; + case 85: goto st169; + } + goto st0; st154: if ( ++p == pe ) goto _test_eof154; case 154: -#line 3600 "http_parser.c" - if ( (*p) == 80 ) + if ( (*p) == 83 ) goto st155; goto st0; st155: @@ -3611,8 +3661,8 @@ st156: if ( ++p == pe ) goto _test_eof156; case 156: - if ( (*p) == 73 ) - goto st157; + if ( (*p) == 32 ) + goto tr187; goto st0; st157: if ( ++p == pe ) @@ -3625,117 +3675,114 @@ st158: if ( ++p == pe ) goto _test_eof158; case 158: - if ( (*p) == 78 ) + if ( (*p) == 80 ) goto st159; goto st0; st159: if ( ++p == pe ) goto _test_eof159; case 159: - if ( (*p) == 83 ) - goto st160; + switch( (*p) ) { + case 70: goto st160; + case 80: goto st164; + } goto st0; st160: if ( ++p == pe ) goto _test_eof160; case 160: - if ( (*p) == 32 ) - goto tr192; + if ( (*p) == 73 ) + goto st161; goto st0; -tr337: -#line 199 "http_parser.rl" - { - if(parser->on_message_begin) { - callback_return_value = parser->on_message_begin(parser); - if (callback_return_value != 0) { - parser->flags |= ERROR; - return; - } - } - } - goto st161; st161: if ( ++p == pe ) goto _test_eof161; case 161: -#line 3662 "http_parser.c" - switch( (*p) ) { - case 79: goto st162; - case 82: goto st165; - case 85: goto st177; - } + if ( (*p) == 78 ) + goto st162; goto st0; st162: if ( ++p == pe ) goto _test_eof162; case 162: - if ( (*p) == 83 ) + if ( (*p) == 68 ) goto st163; goto st0; st163: if ( ++p == pe ) goto _test_eof163; case 163: - if ( (*p) == 84 ) - goto st164; + if ( (*p) == 32 ) + goto tr195; goto st0; st164: if ( ++p == pe ) goto _test_eof164; case 164: - if ( (*p) == 32 ) - goto tr198; + if ( (*p) == 65 ) + goto st165; goto st0; st165: if ( ++p == pe ) goto _test_eof165; case 165: - if ( (*p) == 79 ) + if ( (*p) == 84 ) goto st166; goto st0; st166: if ( ++p == pe ) goto _test_eof166; case 166: - if ( (*p) == 80 ) + if ( (*p) == 67 ) goto st167; goto st0; st167: if ( ++p == pe ) goto _test_eof167; case 167: - switch( (*p) ) { - case 70: goto st168; - case 80: goto st172; - } + if ( (*p) == 72 ) + goto st168; goto st0; st168: if ( ++p == pe ) goto _test_eof168; case 168: - if ( (*p) == 73 ) - goto st169; + if ( (*p) == 32 ) + goto tr200; goto st0; st169: if ( ++p == pe ) goto _test_eof169; case 169: - if ( (*p) == 78 ) + if ( (*p) == 84 ) goto st170; goto st0; st170: if ( ++p == pe ) goto _test_eof170; case 170: - if ( (*p) == 68 ) - goto st171; + if ( (*p) == 32 ) + goto tr202; goto st0; +tr318: +#line 213 "http_parser.rl" + { + if(parser->on_message_begin) { + callback_return_value = parser->on_message_begin(parser); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } + } + } + goto st171; st171: if ( ++p == pe ) goto _test_eof171; case 171: - if ( (*p) == 32 ) - goto tr206; +#line 3784 "http_parser.c" + if ( (*p) == 82 ) + goto st172; goto st0; st172: if ( ++p == pe ) @@ -3748,187 +3795,104 @@ st173: if ( ++p == pe ) goto _test_eof173; case 173: - if ( (*p) == 84 ) + if ( (*p) == 67 ) goto st174; goto st0; st174: if ( ++p == pe ) goto _test_eof174; case 174: - if ( (*p) == 67 ) + if ( (*p) == 69 ) goto st175; goto st0; st175: if ( ++p == pe ) goto _test_eof175; case 175: - if ( (*p) == 72 ) - goto st176; + if ( (*p) == 32 ) + goto tr207; goto st0; +tr319: +#line 213 "http_parser.rl" + { + if(parser->on_message_begin) { + callback_return_value = parser->on_message_begin(parser); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } + } + } + goto st176; st176: if ( ++p == pe ) goto _test_eof176; case 176: - if ( (*p) == 32 ) - goto tr211; +#line 3832 "http_parser.c" + if ( (*p) == 78 ) + goto st177; goto st0; st177: if ( ++p == pe ) goto _test_eof177; case 177: - if ( (*p) == 84 ) + if ( (*p) == 76 ) goto st178; goto st0; st178: if ( ++p == pe ) goto _test_eof178; case 178: - if ( (*p) == 32 ) - goto tr213; + if ( (*p) == 79 ) + goto st179; goto st0; -tr338: -#line 199 "http_parser.rl" - { - if(parser->on_message_begin) { - callback_return_value = parser->on_message_begin(parser); - if (callback_return_value != 0) { - parser->flags |= ERROR; - return; - } - } - } - goto st179; st179: if ( ++p == pe ) goto _test_eof179; case 179: -#line 3806 "http_parser.c" - if ( (*p) == 82 ) + if ( (*p) == 67 ) goto st180; goto st0; st180: if ( ++p == pe ) goto _test_eof180; case 180: - if ( (*p) == 65 ) + if ( (*p) == 75 ) goto st181; goto st0; st181: if ( ++p == pe ) goto _test_eof181; case 181: - if ( (*p) == 67 ) - goto st182; - goto st0; -st182: - if ( ++p == pe ) - goto _test_eof182; -case 182: - if ( (*p) == 69 ) - goto st183; - goto st0; -st183: - if ( ++p == pe ) - goto _test_eof183; -case 183: if ( (*p) == 32 ) - goto tr218; - goto st0; -tr339: -#line 199 "http_parser.rl" - { - if(parser->on_message_begin) { - callback_return_value = parser->on_message_begin(parser); - if (callback_return_value != 0) { - parser->flags |= ERROR; - return; - } - } - } - goto st184; -st184: - if ( ++p == pe ) - goto _test_eof184; -case 184: -#line 3854 "http_parser.c" - if ( (*p) == 78 ) - goto st185; - goto st0; -st185: - if ( ++p == pe ) - goto _test_eof185; -case 185: - if ( (*p) == 76 ) - goto st186; - goto st0; -st186: - if ( ++p == pe ) - goto _test_eof186; -case 186: - if ( (*p) == 79 ) - goto st187; - goto st0; -st187: - if ( ++p == pe ) - goto _test_eof187; -case 187: - if ( (*p) == 67 ) - goto st188; - goto st0; -st188: - if ( ++p == pe ) - goto _test_eof188; -case 188: - if ( (*p) == 75 ) - goto st189; - goto st0; -st189: - if ( ++p == pe ) - goto _test_eof189; -case 189: - if ( (*p) == 32 ) - goto tr224; + goto tr213; goto st0; -tr246: - cs = 283; -#line 189 "http_parser.rl" +tr232: + cs = 269; +#line 203 "http_parser.rl" { if(parser->on_headers_complete) { callback_return_value = parser->on_headers_complete(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } -#line 262 "http_parser.rl" +#line 282 "http_parser.rl" { - if (parser->flags & CHUNKED) { + if (parser->transfer_encoding == HTTP_CHUNKED) { cs = 2; } else { - /* this is pretty stupid. i'd prefer to combine this with - * skip_chunk_data */ - if (parser->content_length < 0) { - /* If we didn't get a content length; if not keep-alive - * just read body until EOF */ - if (!http_parser_should_keep_alive(parser)) { - parser->flags |= EAT_FOREVER; - parser->chunk_size = REMAINING; - } else { - /* Otherwise, if keep-alive, then assume the message - * has no body. */ - parser->chunk_size = parser->content_length = 0; - } - } else { - parser->chunk_size = parser->content_length; - } - p += 1; + /* this is pretty stupid. i'd prefer to combine this with skip_chunk_data */ + parser->chunk_size = parser->content_length; + p += 1; - SKIP_BODY(MIN(REMAINING, parser->chunk_size)); + SKIP_BODY(MIN(REMAINING, parser->content_length)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } p--; @@ -3938,1878 +3902,1860 @@ tr246: } } goto _again; -st283: +st269: if ( ++p == pe ) - goto _test_eof283; -case 283: -#line 3946 "http_parser.c" + goto _test_eof269; +case 269: +#line 3910 "http_parser.c" if ( (*p) == 72 ) - goto tr340; + goto tr320; goto st0; -tr340: -#line 199 "http_parser.rl" +tr320: +#line 213 "http_parser.rl" { if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } - goto st190; -st190: + goto st182; +st182: if ( ++p == pe ) - goto _test_eof190; -case 190: -#line 3966 "http_parser.c" + goto _test_eof182; +case 182: +#line 3930 "http_parser.c" if ( (*p) == 84 ) - goto st191; + goto st183; goto st0; -st191: +st183: if ( ++p == pe ) - goto _test_eof191; -case 191: + goto _test_eof183; +case 183: if ( (*p) == 84 ) - goto st192; + goto st184; goto st0; -st192: +st184: if ( ++p == pe ) - goto _test_eof192; -case 192: + goto _test_eof184; +case 184: if ( (*p) == 80 ) - goto st193; + goto st185; goto st0; -st193: +st185: if ( ++p == pe ) - goto _test_eof193; -case 193: + goto _test_eof185; +case 185: if ( (*p) == 47 ) - goto st194; + goto st186; goto st0; -st194: +st186: if ( ++p == pe ) - goto _test_eof194; -case 194: - switch( (*p) ) { - case 48: goto st195; - case 49: goto st274; - } - if ( 50 <= (*p) && (*p) <= 57 ) - goto st278; + goto _test_eof186; +case 186: + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr218; goto st0; -st195: +tr218: +#line 243 "http_parser.rl" + { + parser->version_major *= 10; + parser->version_major += *p - '0'; + } + goto st187; +st187: if ( ++p == pe ) - goto _test_eof195; -case 195: + goto _test_eof187; +case 187: +#line 3973 "http_parser.c" if ( (*p) == 46 ) - goto st196; + goto st188; goto st0; -st196: +st188: if ( ++p == pe ) - goto _test_eof196; -case 196: - if ( (*p) == 57 ) - goto st273; - if ( 48 <= (*p) && (*p) <= 56 ) - goto st197; + goto _test_eof188; +case 188: + if ( 48 <= (*p) && (*p) <= 57 ) + goto tr220; goto st0; -st197: +tr220: +#line 248 "http_parser.rl" + { + parser->version_minor *= 10; + parser->version_minor += *p - '0'; + } + goto st189; +st189: if ( ++p == pe ) - goto _test_eof197; -case 197: + goto _test_eof189; +case 189: +#line 3995 "http_parser.c" if ( (*p) == 32 ) - goto st198; + goto st190; goto st0; -tr323: -#line 231 "http_parser.rl" - { parser->version = HTTP_VERSION_09; } - goto st198; -tr327: -#line 230 "http_parser.rl" - { parser->version = HTTP_VERSION_10; } - goto st198; -tr328: -#line 229 "http_parser.rl" - { parser->version = HTTP_VERSION_11; } - goto st198; -st198: +st190: if ( ++p == pe ) - goto _test_eof198; -case 198: -#line 4041 "http_parser.c" + goto _test_eof190; +case 190: if ( 48 <= (*p) && (*p) <= 57 ) - goto tr236; + goto tr222; goto st0; -tr236: -#line 219 "http_parser.rl" +tr222: +#line 232 "http_parser.rl" { parser->status_code *= 10; parser->status_code += *p - '0'; } - goto st199; -st199: + goto st191; +st191: if ( ++p == pe ) - goto _test_eof199; -case 199: -#line 4056 "http_parser.c" + goto _test_eof191; +case 191: +#line 4017 "http_parser.c" if ( 48 <= (*p) && (*p) <= 57 ) - goto tr237; + goto tr223; goto st0; -tr237: -#line 219 "http_parser.rl" +tr223: +#line 232 "http_parser.rl" { parser->status_code *= 10; parser->status_code += *p - '0'; } - goto st200; -st200: + goto st192; +st192: if ( ++p == pe ) - goto _test_eof200; -case 200: -#line 4071 "http_parser.c" + goto _test_eof192; +case 192: +#line 4032 "http_parser.c" if ( 48 <= (*p) && (*p) <= 57 ) - goto tr238; + goto tr224; goto st0; -tr238: -#line 219 "http_parser.rl" +tr224: +#line 232 "http_parser.rl" { parser->status_code *= 10; parser->status_code += *p - '0'; } - goto st201; -st201: + goto st193; +st193: if ( ++p == pe ) - goto _test_eof201; -case 201: -#line 4086 "http_parser.c" + goto _test_eof193; +case 193: +#line 4047 "http_parser.c" switch( (*p) ) { - case 13: goto st202; - case 32: goto st272; + case 13: goto st194; + case 32: goto st265; } goto st0; -tr250: -#line 128 "http_parser.rl" +tr236: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } -#line 159 "http_parser.rl" +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st202; -tr253: -#line 159 "http_parser.rl" + goto st194; +tr239: +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st202; -tr272: -#line 227 "http_parser.rl" - { parser->keep_alive = 0; } -#line 159 "http_parser.rl" + goto st194; +tr258: +#line 241 "http_parser.rl" + { parser->keep_alive = FALSE; } +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st202; -tr282: -#line 226 "http_parser.rl" - { parser->keep_alive = 1; } -#line 159 "http_parser.rl" + goto st194; +tr268: +#line 240 "http_parser.rl" + { parser->keep_alive = TRUE; } +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st202; -tr322: -#line 224 "http_parser.rl" - { parser->flags |= CHUNKED; } -#line 159 "http_parser.rl" + goto st194; +tr309: +#line 237 "http_parser.rl" + { parser->transfer_encoding = HTTP_IDENTITY; } +#line 153 "http_parser.rl" { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st202; -st202: + goto st194; +st194: if ( ++p == pe ) - goto _test_eof202; -case 202: -#line 4147 "http_parser.c" + goto _test_eof194; +case 194: +#line 4128 "http_parser.c" if ( (*p) == 10 ) - goto st203; + goto st195; goto st0; -st203: +st195: if ( ++p == pe ) - goto _test_eof203; -case 203: + goto _test_eof195; +case 195: switch( (*p) ) { - case 13: goto st204; - case 33: goto tr243; - case 67: goto tr244; - case 84: goto tr245; - case 99: goto tr244; - case 116: goto tr245; - case 124: goto tr243; - case 126: goto tr243; + case 13: goto st196; + case 33: goto tr229; + case 67: goto tr230; + case 84: goto tr231; + case 99: goto tr230; + case 116: goto tr231; + case 124: goto tr229; + case 126: goto tr229; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto tr243; + goto tr229; } else if ( (*p) >= 35 ) - goto tr243; + goto tr229; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto tr243; + goto tr229; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto tr243; + goto tr229; } else - goto tr243; + goto tr229; } else - goto tr243; + goto tr229; goto st0; -st204: +st196: if ( ++p == pe ) - goto _test_eof204; -case 204: + goto _test_eof196; +case 196: if ( (*p) == 10 ) - goto tr246; + goto tr232; goto st0; -tr243: -#line 123 "http_parser.rl" +tr229: +#line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st205; -st205: + goto st197; +st197: if ( ++p == pe ) - goto _test_eof205; -case 205: -#line 4201 "http_parser.c" + goto _test_eof197; +case 197: +#line 4182 "http_parser.c" switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -tr248: -#line 153 "http_parser.rl" +tr234: +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st206; -st206: + goto st198; +st198: if ( ++p == pe ) - goto _test_eof206; -case 206: -#line 4238 "http_parser.c" + goto _test_eof198; +case 198: +#line 4223 "http_parser.c" switch( (*p) ) { - case 13: goto tr250; - case 32: goto st206; + case 13: goto tr236; + case 32: goto st198; } - goto tr249; -tr249: -#line 128 "http_parser.rl" + goto tr235; +tr235: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st207; -st207: + goto st199; +st199: if ( ++p == pe ) - goto _test_eof207; -case 207: -#line 4255 "http_parser.c" + goto _test_eof199; +case 199: +#line 4240 "http_parser.c" if ( (*p) == 13 ) - goto tr253; - goto st207; -tr244: -#line 123 "http_parser.rl" + goto tr239; + goto st199; +tr230: +#line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st208; -st208: + goto st200; +st200: if ( ++p == pe ) - goto _test_eof208; -case 208: -#line 4270 "http_parser.c" + goto _test_eof200; +case 200: +#line 4255 "http_parser.c" switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 79: goto st209; - case 111: goto st209; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 79: goto st201; + case 111: goto st201; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st209: +st201: if ( ++p == pe ) - goto _test_eof209; -case 209: + goto _test_eof201; +case 201: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st210; - case 110: goto st210; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st202; + case 110: goto st202; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st210: +st202: if ( ++p == pe ) - goto _test_eof210; -case 210: + goto _test_eof202; +case 202: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st211; - case 84: goto st234; - case 110: goto st211; - case 116: goto st234; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st203; + case 84: goto st226; + case 110: goto st203; + case 116: goto st226; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st211: +st203: if ( ++p == pe ) - goto _test_eof211; -case 211: + goto _test_eof203; +case 203: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 69: goto st212; - case 101: goto st212; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 69: goto st204; + case 101: goto st204; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st212: +st204: if ( ++p == pe ) - goto _test_eof212; -case 212: + goto _test_eof204; +case 204: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 67: goto st213; - case 99: goto st213; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 67: goto st205; + case 99: goto st205; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st213: +st205: if ( ++p == pe ) - goto _test_eof213; -case 213: + goto _test_eof205; +case 205: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 84: goto st214; - case 116: goto st214; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 84: goto st206; + case 116: goto st206; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st214: +st206: if ( ++p == pe ) - goto _test_eof214; -case 214: + goto _test_eof206; +case 206: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 73: goto st215; - case 105: goto st215; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 73: goto st207; + case 105: goto st207; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st215: +st207: if ( ++p == pe ) - goto _test_eof215; -case 215: + goto _test_eof207; +case 207: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 79: goto st216; - case 111: goto st216; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 79: goto st208; + case 111: goto st208; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st216: +st208: if ( ++p == pe ) - goto _test_eof216; -case 216: + goto _test_eof208; +case 208: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st217; - case 110: goto st217; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st209; + case 110: goto st209; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st217: +st209: if ( ++p == pe ) - goto _test_eof217; -case 217: + goto _test_eof209; +case 209: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr264; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr250; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -tr264: -#line 153 "http_parser.rl" +tr250: +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st218; -st218: + goto st210; +st210: if ( ++p == pe ) - goto _test_eof218; -case 218: -#line 4579 "http_parser.c" - switch( (*p) ) { - case 13: goto tr250; - case 32: goto st218; - case 67: goto tr266; - case 75: goto tr267; - case 99: goto tr266; - case 107: goto tr267; - } - goto tr249; -tr266: -#line 128 "http_parser.rl" + goto _test_eof210; +case 210: +#line 4568 "http_parser.c" + switch( (*p) ) { + case 13: goto tr236; + case 32: goto st210; + case 67: goto tr252; + case 75: goto tr253; + case 99: goto tr252; + case 107: goto tr253; + } + goto tr235; +tr252: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st219; -st219: + goto st211; +st211: if ( ++p == pe ) - goto _test_eof219; -case 219: -#line 4600 "http_parser.c" + goto _test_eof211; +case 211: +#line 4589 "http_parser.c" switch( (*p) ) { - case 13: goto tr253; - case 76: goto st220; - case 108: goto st220; + case 13: goto tr239; + case 76: goto st212; + case 108: goto st212; } - goto st207; -st220: + goto st199; +st212: if ( ++p == pe ) - goto _test_eof220; -case 220: + goto _test_eof212; +case 212: switch( (*p) ) { - case 13: goto tr253; - case 79: goto st221; - case 111: goto st221; + case 13: goto tr239; + case 79: goto st213; + case 111: goto st213; } - goto st207; -st221: + goto st199; +st213: if ( ++p == pe ) - goto _test_eof221; -case 221: + goto _test_eof213; +case 213: switch( (*p) ) { - case 13: goto tr253; - case 83: goto st222; - case 115: goto st222; + case 13: goto tr239; + case 83: goto st214; + case 115: goto st214; } - goto st207; -st222: + goto st199; +st214: if ( ++p == pe ) - goto _test_eof222; -case 222: + goto _test_eof214; +case 214: switch( (*p) ) { - case 13: goto tr253; - case 69: goto st223; - case 101: goto st223; + case 13: goto tr239; + case 69: goto st215; + case 101: goto st215; } - goto st207; -st223: + goto st199; +st215: if ( ++p == pe ) - goto _test_eof223; -case 223: + goto _test_eof215; +case 215: if ( (*p) == 13 ) - goto tr272; - goto st207; -tr267: -#line 128 "http_parser.rl" + goto tr258; + goto st199; +tr253: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st224; -st224: + goto st216; +st216: if ( ++p == pe ) - goto _test_eof224; -case 224: -#line 4655 "http_parser.c" + goto _test_eof216; +case 216: +#line 4644 "http_parser.c" switch( (*p) ) { - case 13: goto tr253; - case 69: goto st225; - case 101: goto st225; + case 13: goto tr239; + case 69: goto st217; + case 101: goto st217; } - goto st207; -st225: + goto st199; +st217: if ( ++p == pe ) - goto _test_eof225; -case 225: + goto _test_eof217; +case 217: switch( (*p) ) { - case 13: goto tr253; - case 69: goto st226; - case 101: goto st226; + case 13: goto tr239; + case 69: goto st218; + case 101: goto st218; } - goto st207; -st226: + goto st199; +st218: if ( ++p == pe ) - goto _test_eof226; -case 226: + goto _test_eof218; +case 218: switch( (*p) ) { - case 13: goto tr253; - case 80: goto st227; - case 112: goto st227; + case 13: goto tr239; + case 80: goto st219; + case 112: goto st219; } - goto st207; -st227: + goto st199; +st219: if ( ++p == pe ) - goto _test_eof227; -case 227: + goto _test_eof219; +case 219: switch( (*p) ) { - case 13: goto tr253; - case 45: goto st228; + case 13: goto tr239; + case 45: goto st220; } - goto st207; -st228: + goto st199; +st220: if ( ++p == pe ) - goto _test_eof228; -case 228: + goto _test_eof220; +case 220: switch( (*p) ) { - case 13: goto tr253; - case 65: goto st229; - case 97: goto st229; + case 13: goto tr239; + case 65: goto st221; + case 97: goto st221; } - goto st207; -st229: + goto st199; +st221: if ( ++p == pe ) - goto _test_eof229; -case 229: + goto _test_eof221; +case 221: switch( (*p) ) { - case 13: goto tr253; - case 76: goto st230; - case 108: goto st230; + case 13: goto tr239; + case 76: goto st222; + case 108: goto st222; } - goto st207; -st230: + goto st199; +st222: if ( ++p == pe ) - goto _test_eof230; -case 230: + goto _test_eof222; +case 222: switch( (*p) ) { - case 13: goto tr253; - case 73: goto st231; - case 105: goto st231; + case 13: goto tr239; + case 73: goto st223; + case 105: goto st223; } - goto st207; -st231: + goto st199; +st223: if ( ++p == pe ) - goto _test_eof231; -case 231: + goto _test_eof223; +case 223: switch( (*p) ) { - case 13: goto tr253; - case 86: goto st232; - case 118: goto st232; + case 13: goto tr239; + case 86: goto st224; + case 118: goto st224; } - goto st207; -st232: + goto st199; +st224: if ( ++p == pe ) - goto _test_eof232; -case 232: + goto _test_eof224; +case 224: switch( (*p) ) { - case 13: goto tr253; - case 69: goto st233; - case 101: goto st233; + case 13: goto tr239; + case 69: goto st225; + case 101: goto st225; } - goto st207; -st233: + goto st199; +st225: if ( ++p == pe ) - goto _test_eof233; -case 233: + goto _test_eof225; +case 225: if ( (*p) == 13 ) - goto tr282; - goto st207; -st234: + goto tr268; + goto st199; +st226: if ( ++p == pe ) - goto _test_eof234; -case 234: + goto _test_eof226; +case 226: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 69: goto st235; - case 101: goto st235; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 69: goto st227; + case 101: goto st227; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st235: +st227: if ( ++p == pe ) - goto _test_eof235; -case 235: + goto _test_eof227; +case 227: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st236; - case 110: goto st236; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st228; + case 110: goto st228; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st236: +st228: if ( ++p == pe ) - goto _test_eof236; -case 236: + goto _test_eof228; +case 228: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 84: goto st237; - case 116: goto st237; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 84: goto st229; + case 116: goto st229; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st237: +st229: if ( ++p == pe ) - goto _test_eof237; -case 237: + goto _test_eof229; +case 229: switch( (*p) ) { - case 33: goto st205; - case 45: goto st238; - case 46: goto st205; - case 58: goto tr248; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 45: goto st230; + case 46: goto st197; + case 58: goto tr234; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 48 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else if ( (*p) >= 65 ) - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st238: +st230: if ( ++p == pe ) - goto _test_eof238; -case 238: + goto _test_eof230; +case 230: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 76: goto st239; - case 108: goto st239; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 76: goto st231; + case 108: goto st231; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st239: +st231: if ( ++p == pe ) - goto _test_eof239; -case 239: + goto _test_eof231; +case 231: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 69: goto st240; - case 101: goto st240; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 69: goto st232; + case 101: goto st232; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st240: +st232: if ( ++p == pe ) - goto _test_eof240; -case 240: + goto _test_eof232; +case 232: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st241; - case 110: goto st241; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st233; + case 110: goto st233; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st241: +st233: if ( ++p == pe ) - goto _test_eof241; -case 241: + goto _test_eof233; +case 233: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 71: goto st242; - case 103: goto st242; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 71: goto st234; + case 103: goto st234; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st242: +st234: if ( ++p == pe ) - goto _test_eof242; -case 242: + goto _test_eof234; +case 234: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 84: goto st243; - case 116: goto st243; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 84: goto st235; + case 116: goto st235; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st243: +st235: if ( ++p == pe ) - goto _test_eof243; -case 243: + goto _test_eof235; +case 235: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 72: goto st244; - case 104: goto st244; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 72: goto st236; + case 104: goto st236; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st244: +st236: if ( ++p == pe ) - goto _test_eof244; -case 244: + goto _test_eof236; +case 236: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr293; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr279; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -tr293: -#line 153 "http_parser.rl" +tr279: +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st245; -st245: + goto st237; +st237: if ( ++p == pe ) - goto _test_eof245; -case 245: -#line 5085 "http_parser.c" + goto _test_eof237; +case 237: +#line 5078 "http_parser.c" switch( (*p) ) { - case 13: goto tr250; - case 32: goto st245; + case 13: goto tr236; + case 32: goto st237; } if ( 48 <= (*p) && (*p) <= 57 ) - goto tr295; - goto tr249; -tr295: -#line 209 "http_parser.rl" + goto tr281; + goto tr235; +tr281: +#line 223 "http_parser.rl" { - if (parser->content_length == -1) parser->content_length = 0; if (parser->content_length > INT_MAX) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } parser->content_length *= 10; parser->content_length += *p - '0'; } -#line 128 "http_parser.rl" +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st246; -tr296: -#line 209 "http_parser.rl" + goto st238; +tr282: +#line 223 "http_parser.rl" { - if (parser->content_length == -1) parser->content_length = 0; if (parser->content_length > INT_MAX) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } parser->content_length *= 10; parser->content_length += *p - '0'; } - goto st246; -st246: + goto st238; +st238: if ( ++p == pe ) - goto _test_eof246; -case 246: -#line 5126 "http_parser.c" + goto _test_eof238; +case 238: +#line 5117 "http_parser.c" if ( (*p) == 13 ) - goto tr253; + goto tr239; if ( 48 <= (*p) && (*p) <= 57 ) - goto tr296; - goto st207; -tr245: -#line 123 "http_parser.rl" + goto tr282; + goto st199; +tr231: +#line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st247; -st247: + goto st239; +st239: if ( ++p == pe ) - goto _test_eof247; -case 247: -#line 5143 "http_parser.c" + goto _test_eof239; +case 239: +#line 5134 "http_parser.c" switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 82: goto st248; - case 114: goto st248; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 82: goto st240; + case 114: goto st240; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st248: +st240: if ( ++p == pe ) - goto _test_eof248; -case 248: + goto _test_eof240; +case 240: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 65: goto st249; - case 97: goto st249; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 65: goto st241; + case 97: goto st241; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 66 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st249: +st241: if ( ++p == pe ) - goto _test_eof249; -case 249: + goto _test_eof241; +case 241: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st250; - case 110: goto st250; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st242; + case 110: goto st242; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st250: +st242: if ( ++p == pe ) - goto _test_eof250; -case 250: + goto _test_eof242; +case 242: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 83: goto st251; - case 115: goto st251; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 83: goto st243; + case 115: goto st243; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st251: +st243: if ( ++p == pe ) - goto _test_eof251; -case 251: + goto _test_eof243; +case 243: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 70: goto st252; - case 102: goto st252; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 70: goto st244; + case 102: goto st244; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st252: +st244: if ( ++p == pe ) - goto _test_eof252; -case 252: + goto _test_eof244; +case 244: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 69: goto st253; - case 101: goto st253; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 69: goto st245; + case 101: goto st245; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st253: +st245: if ( ++p == pe ) - goto _test_eof253; -case 253: + goto _test_eof245; +case 245: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 82: goto st254; - case 114: goto st254; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 82: goto st246; + case 114: goto st246; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st254: +st246: if ( ++p == pe ) - goto _test_eof254; -case 254: + goto _test_eof246; +case 246: switch( (*p) ) { - case 33: goto st205; - case 45: goto st255; - case 46: goto st205; - case 58: goto tr248; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 45: goto st247; + case 46: goto st197; + case 58: goto tr234; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 48 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else if ( (*p) >= 65 ) - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st255: +st247: if ( ++p == pe ) - goto _test_eof255; -case 255: + goto _test_eof247; +case 247: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 69: goto st256; - case 101: goto st256; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 69: goto st248; + case 101: goto st248; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st256: +st248: if ( ++p == pe ) - goto _test_eof256; -case 256: + goto _test_eof248; +case 248: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st257; - case 110: goto st257; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st249; + case 110: goto st249; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st257: +st249: if ( ++p == pe ) - goto _test_eof257; -case 257: + goto _test_eof249; +case 249: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 67: goto st258; - case 99: goto st258; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 67: goto st250; + case 99: goto st250; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st258: +st250: if ( ++p == pe ) - goto _test_eof258; -case 258: + goto _test_eof250; +case 250: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 79: goto st259; - case 111: goto st259; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 79: goto st251; + case 111: goto st251; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st259: +st251: if ( ++p == pe ) - goto _test_eof259; -case 259: + goto _test_eof251; +case 251: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 68: goto st260; - case 100: goto st260; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 68: goto st252; + case 100: goto st252; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st260: +st252: if ( ++p == pe ) - goto _test_eof260; -case 260: + goto _test_eof252; +case 252: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 73: goto st261; - case 105: goto st261; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 73: goto st253; + case 105: goto st253; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st261: +st253: if ( ++p == pe ) - goto _test_eof261; -case 261: + goto _test_eof253; +case 253: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 78: goto st262; - case 110: goto st262; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 78: goto st254; + case 110: goto st254; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st262: +st254: if ( ++p == pe ) - goto _test_eof262; -case 262: + goto _test_eof254; +case 254: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr248; - case 71: goto st263; - case 103: goto st263; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr234; + case 71: goto st255; + case 103: goto st255; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -st263: +st255: if ( ++p == pe ) - goto _test_eof263; -case 263: + goto _test_eof255; +case 255: switch( (*p) ) { - case 33: goto st205; - case 58: goto tr313; - case 124: goto st205; - case 126: goto st205; + case 33: goto st197; + case 58: goto tr299; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st205; + goto st197; } else if ( (*p) >= 35 ) - goto st205; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st205; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st205; + goto st197; } else - goto st205; + goto st197; } else - goto st205; + goto st197; goto st0; -tr313: -#line 153 "http_parser.rl" +tr299: +#line 238 "http_parser.rl" + { parser->transfer_encoding = HTTP_CHUNKED; } +#line 143 "http_parser.rl" { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st264; -st264: + goto st256; +st256: if ( ++p == pe ) - goto _test_eof264; -case 264: -#line 5657 "http_parser.c" + goto _test_eof256; +case 256: +#line 5654 "http_parser.c" switch( (*p) ) { - case 13: goto tr250; - case 32: goto st264; - case 67: goto tr315; - case 99: goto tr315; + case 13: goto tr236; + case 32: goto st256; + case 105: goto tr301; } - goto tr249; -tr315: -#line 128 "http_parser.rl" + goto tr235; +tr301: +#line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st265; -st265: + goto st257; +st257: if ( ++p == pe ) - goto _test_eof265; -case 265: -#line 5676 "http_parser.c" + goto _test_eof257; +case 257: +#line 5672 "http_parser.c" switch( (*p) ) { - case 13: goto tr253; - case 72: goto st266; - case 104: goto st266; + case 13: goto tr239; + case 100: goto st258; } - goto st207; -st266: + goto st199; +st258: if ( ++p == pe ) - goto _test_eof266; -case 266: + goto _test_eof258; +case 258: switch( (*p) ) { - case 13: goto tr253; - case 85: goto st267; - case 117: goto st267; + case 13: goto tr239; + case 101: goto st259; } - goto st207; -st267: + goto st199; +st259: if ( ++p == pe ) - goto _test_eof267; -case 267: + goto _test_eof259; +case 259: switch( (*p) ) { - case 13: goto tr253; - case 78: goto st268; - case 110: goto st268; + case 13: goto tr239; + case 110: goto st260; } - goto st207; -st268: + goto st199; +st260: if ( ++p == pe ) - goto _test_eof268; -case 268: + goto _test_eof260; +case 260: switch( (*p) ) { - case 13: goto tr253; - case 75: goto st269; - case 107: goto st269; + case 13: goto tr239; + case 116: goto st261; } - goto st207; -st269: + goto st199; +st261: if ( ++p == pe ) - goto _test_eof269; -case 269: + goto _test_eof261; +case 261: switch( (*p) ) { - case 13: goto tr253; - case 69: goto st270; - case 101: goto st270; + case 13: goto tr239; + case 105: goto st262; } - goto st207; -st270: + goto st199; +st262: + if ( ++p == pe ) + goto _test_eof262; +case 262: + switch( (*p) ) { + case 13: goto tr239; + case 116: goto st263; + } + goto st199; +st263: if ( ++p == pe ) - goto _test_eof270; -case 270: + goto _test_eof263; +case 263: switch( (*p) ) { - case 13: goto tr253; - case 68: goto st271; - case 100: goto st271; + case 13: goto tr239; + case 121: goto st264; } - goto st207; -st271: + goto st199; +st264: if ( ++p == pe ) - goto _test_eof271; -case 271: + goto _test_eof264; +case 264: if ( (*p) == 13 ) - goto tr322; - goto st207; -st272: + goto tr309; + goto st199; +st265: if ( ++p == pe ) - goto _test_eof272; -case 272: + goto _test_eof265; +case 265: if ( (*p) == 13 ) - goto st202; + goto st194; if ( (*p) > 9 ) { if ( 11 <= (*p) ) - goto st272; + goto st265; } else if ( (*p) >= 0 ) - goto st272; - goto st0; -st273: - if ( ++p == pe ) - goto _test_eof273; -case 273: - if ( (*p) == 32 ) - goto tr323; - goto st0; -st274: - if ( ++p == pe ) - goto _test_eof274; -case 274: - if ( (*p) == 46 ) - goto st275; - goto st0; -st275: - if ( ++p == pe ) - goto _test_eof275; -case 275: - switch( (*p) ) { - case 48: goto st276; - case 49: goto st277; - } - if ( 50 <= (*p) && (*p) <= 57 ) - goto st197; - goto st0; -st276: - if ( ++p == pe ) - goto _test_eof276; -case 276: - if ( (*p) == 32 ) - goto tr327; - goto st0; -st277: - if ( ++p == pe ) - goto _test_eof277; -case 277: - if ( (*p) == 32 ) - goto tr328; - goto st0; -st278: - if ( ++p == pe ) - goto _test_eof278; -case 278: - if ( (*p) == 46 ) - goto st279; - goto st0; -st279: - if ( ++p == pe ) - goto _test_eof279; -case 279: - if ( 48 <= (*p) && (*p) <= 57 ) - goto st197; + goto st265; goto st0; } _test_eof1: cs = 1; goto _test_eof; - _test_eof280: cs = 280; goto _test_eof; + _test_eof266: cs = 266; goto _test_eof; _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; - _test_eof281: cs = 281; goto _test_eof; + _test_eof267: cs = 267; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; @@ -5823,9 +5769,9 @@ case 279: _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; + _test_eof268: cs = 268; goto _test_eof; _test_eof20: cs = 20; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; - _test_eof282: cs = 282; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; @@ -5986,6 +5932,7 @@ case 279: _test_eof179: cs = 179; goto _test_eof; _test_eof180: cs = 180; goto _test_eof; _test_eof181: cs = 181; goto _test_eof; + _test_eof269: cs = 269; goto _test_eof; _test_eof182: cs = 182; goto _test_eof; _test_eof183: cs = 183; goto _test_eof; _test_eof184: cs = 184; goto _test_eof; @@ -5994,7 +5941,6 @@ case 279: _test_eof187: cs = 187; goto _test_eof; _test_eof188: cs = 188; goto _test_eof; _test_eof189: cs = 189; goto _test_eof; - _test_eof283: cs = 283; goto _test_eof; _test_eof190: cs = 190; goto _test_eof; _test_eof191: cs = 191; goto _test_eof; _test_eof192: cs = 192; goto _test_eof; @@ -6071,25 +6017,11 @@ case 279: _test_eof263: cs = 263; goto _test_eof; _test_eof264: cs = 264; goto _test_eof; _test_eof265: cs = 265; goto _test_eof; - _test_eof266: cs = 266; goto _test_eof; - _test_eof267: cs = 267; goto _test_eof; - _test_eof268: cs = 268; goto _test_eof; - _test_eof269: cs = 269; goto _test_eof; - _test_eof270: cs = 270; goto _test_eof; - _test_eof271: cs = 271; goto _test_eof; - _test_eof272: cs = 272; goto _test_eof; - _test_eof273: cs = 273; goto _test_eof; - _test_eof274: cs = 274; goto _test_eof; - _test_eof275: cs = 275; goto _test_eof; - _test_eof276: cs = 276; goto _test_eof; - _test_eof277: cs = 277; goto _test_eof; - _test_eof278: cs = 278; goto _test_eof; - _test_eof279: cs = 279; goto _test_eof; _test_eof: {} _out: {} } -#line 482 "http_parser.rl" +#line 469 "http_parser.rl" parser->cs = cs; @@ -6101,11 +6033,26 @@ case 279: CALLBACK(uri); assert(p <= pe && "buffer overflow after parsing execute"); + return(p - buffer); } int -http_parser_has_error (http_parser *parser) +http_parser_has_error (http_parser *parser) { - if (parser->flags & ERROR) return 1; + if (parser->error) return TRUE; return parser->cs == http_parser_error; } + +int +http_parser_should_keep_alive (http_parser *parser) +{ + if (parser->keep_alive == -1) + if (parser->version_major == 1) + return (parser->version_minor != 0); + else if (parser->version_major == 0) + return FALSE; + else + return TRUE; + else + return parser->keep_alive; +} diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index 4787a655a6..9b699dc483 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -2,7 +2,7 @@ * Based on Zed Shaw's Mongrel, copyright (c) Zed A. Shaw * * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,34 +10,31 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef http_parser_h #define http_parser_h #ifdef __cplusplus extern "C" { -#endif +#endif -#ifdef _MSC_VER -# include -#endif -#include +#include typedef struct http_parser http_parser; /* Callbacks should return non-zero to indicate an error. The parse will - * then halt execution. - * + * then halt execution. + * * http_data_cb does not return data chunks. It will be call arbitrarally * many times for each string. E.G. you might get 10 callbacks for "on_path" * each providing just a few characters more data. @@ -61,12 +58,11 @@ typedef int (*http_cb) (http_parser*); #define HTTP_TRACE 0x1000 #define HTTP_UNLOCK 0x2000 -enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE }; +/* Transfer Encodings */ +#define HTTP_IDENTITY 0x01 +#define HTTP_CHUNKED 0x02 -#define HTTP_VERSION_OTHER 0x00 -#define HTTP_VERSION_11 0x01 -#define HTTP_VERSION_10 0x02 -#define HTTP_VERSION_09 0x04 +enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE }; struct http_parser { /** PRIVATE **/ @@ -74,29 +70,48 @@ struct http_parser { enum http_parser_type type; size_t chunk_size; - char flags; + + /** + XXX + do this so no other code has to change, but make the field only 1 byte wide + instead of 2 (on x86/x86_64). + + doing this not only shrinks the sizeof this struct by a byte but it ALSO + makes wrapping this in FFI way easier. + */ + union { + struct { + unsigned eating:1; + unsigned error:1; + }; + struct { + unsigned char _flags; + }; + }; size_t body_read; - const char *header_field_mark; - size_t header_field_size; - const char *header_value_mark; - size_t header_value_size; - const char *query_string_mark; - size_t query_string_size; - const char *path_mark; - size_t path_size; - const char *uri_mark; - size_t uri_size; - const char *fragment_mark; - size_t fragment_size; + const char *header_field_mark; + size_t header_field_size; + const char *header_value_mark; + size_t header_value_size; + const char *query_string_mark; + size_t query_string_size; + const char *path_mark; + size_t path_size; + const char *uri_mark; + size_t uri_size; + const char *fragment_mark; + size_t fragment_size; /** READ-ONLY **/ unsigned short status_code; /* responses only */ unsigned short method; /* requests only */ - short version; + short transfer_encoding; + unsigned short version_major; + unsigned short version_minor; short keep_alive; - ssize_t content_length; + size_t content_length; /** PUBLIC **/ void *data; /* A pointer to get hook to the "connection" or "socket" object */ @@ -119,23 +134,17 @@ struct http_parser { }; /* Initializes an http_parser structure. The second argument specifies if - * it will be parsing requests or responses. + * it will be parsing requests or responses. */ void http_parser_init (http_parser *parser, enum http_parser_type); -void http_parser_execute (http_parser *parser, const char *data, size_t len); +size_t http_parser_execute (http_parser *parser, const char *data, size_t len); int http_parser_has_error (http_parser *parser); -static inline int -http_parser_should_keep_alive (http_parser *parser) -{ - if (parser->keep_alive == -1) return (parser->version == HTTP_VERSION_11); - return parser->keep_alive; -} - +int http_parser_should_keep_alive (http_parser *parser); #ifdef __cplusplus } -#endif +#endif #endif diff --git a/deps/http_parser/http_parser.rl b/deps/http_parser/http_parser.rl index e9d014a4f1..bf2da13fd2 100644 --- a/deps/http_parser/http_parser.rl +++ b/deps/http_parser/http_parser.rl @@ -2,7 +2,7 @@ * Based on Zed Shaw's Mongrel, copyright (c) Zed A. Shaw * * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,28 +10,22 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "http_parser.h" #include #include -/* parser->flags */ -#define EATING 0x01 -#define ERROR 0x02 -#define CHUNKED 0x04 -#define EAT_FOREVER 0x10 - static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 @@ -41,14 +35,12 @@ static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }; +#define TRUE 1 +#define FALSE 0 +#define MIN(a,b) (a < b ? a : b) +#define NULL (void*)(0) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -#undef NULL -#define NULL ((void*)(0)) - -#define MAX_FIELD_SIZE (80*1024) +#define MAX_FIELD_SIZE 80*1024 #define REMAINING (unsigned long)(pe - p) #define CALLBACK(FOR) \ @@ -56,36 +48,34 @@ do { \ if (parser->FOR##_mark) { \ parser->FOR##_size += p - parser->FOR##_mark; \ if (parser->FOR##_size > MAX_FIELD_SIZE) { \ - parser->flags |= ERROR; \ - return; \ + parser->error = TRUE; \ + return 0; \ } \ if (parser->on_##FOR) { \ callback_return_value = parser->on_##FOR(parser, \ parser->FOR##_mark, \ p - parser->FOR##_mark); \ } \ - if (callback_return_value != 0) { \ - parser->flags |= ERROR; \ - return; \ - } \ } \ } while(0) #define RESET_PARSER(parser) \ - parser->chunk_size = 0; \ - parser->flags = 0; \ - parser->header_field_mark = NULL; \ - parser->header_value_mark = NULL; \ - parser->query_string_mark = NULL; \ - parser->path_mark = NULL; \ - parser->uri_mark = NULL; \ - parser->fragment_mark = NULL; \ - parser->status_code = 0; \ - parser->method = 0; \ - parser->version = HTTP_VERSION_OTHER; \ - parser->keep_alive = -1; \ - parser->content_length = -1; \ - parser->body_read = 0 + parser->chunk_size = 0; \ + parser->eating = 0; \ + parser->header_field_mark = NULL; \ + parser->header_value_mark = NULL; \ + parser->query_string_mark = NULL; \ + parser->path_mark = NULL; \ + parser->uri_mark = NULL; \ + parser->fragment_mark = NULL; \ + parser->status_code = 0; \ + parser->method = 0; \ + parser->transfer_encoding = HTTP_IDENTITY; \ + parser->version_major = 0; \ + parser->version_minor = 0; \ + parser->keep_alive = -1; \ + parser->content_length = 0; \ + parser->body_read = 0; #define END_REQUEST \ do { \ @@ -107,12 +97,12 @@ do { \ parser->body_read += tmp; \ parser->chunk_size -= tmp; \ if (0 == parser->chunk_size) { \ - parser->flags &= ~EATING; \ - if (!(parser->flags & CHUNKED)) { \ + parser->eating = FALSE; \ + if (parser->transfer_encoding == HTTP_IDENTITY) { \ END_REQUEST; \ } \ } else { \ - parser->flags |= EATING; \ + parser->eating = TRUE; \ } \ } \ } while (0) @@ -152,36 +142,60 @@ do { \ action header_field { CALLBACK(header_field); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_field_mark = NULL; parser->header_field_size = 0; } action header_value { CALLBACK(header_value); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->header_value_mark = NULL; parser->header_value_size = 0; } - action request_uri { + action request_uri { CALLBACK(uri); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->uri_mark = NULL; parser->uri_size = 0; } - action fragment { + action fragment { CALLBACK(fragment); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->fragment_mark = NULL; parser->fragment_size = 0; } - action query_string { + action query_string { CALLBACK(query_string); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->query_string_mark = NULL; parser->query_string_size = 0; } action request_path { CALLBACK(path); + if (callback_return_value != 0) { + parser->error = TRUE; + return 0; + } parser->path_mark = NULL; parser->path_size = 0; } @@ -190,8 +204,8 @@ do { \ if(parser->on_headers_complete) { callback_return_value = parser->on_headers_complete(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } @@ -200,17 +214,16 @@ do { \ if(parser->on_message_begin) { callback_return_value = parser->on_message_begin(parser); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } } action content_length { - if (parser->content_length == -1) parser->content_length = 0; if (parser->content_length > INT_MAX) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } parser->content_length *= 10; parser->content_length += *p - '0'; @@ -221,14 +234,21 @@ do { \ parser->status_code += *p - '0'; } - action use_chunked_encoding { parser->flags |= CHUNKED; } + action use_identity_encoding { parser->transfer_encoding = HTTP_IDENTITY; } + action use_chunked_encoding { parser->transfer_encoding = HTTP_CHUNKED; } - action set_keep_alive { parser->keep_alive = 1; } - action set_not_keep_alive { parser->keep_alive = 0; } + action set_keep_alive { parser->keep_alive = TRUE; } + action set_not_keep_alive { parser->keep_alive = FALSE; } - action version_11 { parser->version = HTTP_VERSION_11; } - action version_10 { parser->version = HTTP_VERSION_10; } - action version_09 { parser->version = HTTP_VERSION_09; } + action version_major { + parser->version_major *= 10; + parser->version_major += *p - '0'; + } + + action version_minor { + parser->version_minor *= 10; + parser->version_minor += *p - '0'; + } action add_to_chunk_size { parser->chunk_size *= 16; @@ -238,15 +258,15 @@ do { \ action skip_chunk_data { SKIP_BODY(MIN(parser->chunk_size, REMAINING)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } - fhold; + fhold; if (parser->chunk_size > REMAINING) { fbreak; } else { - fgoto chunk_end; + fgoto chunk_end; } } @@ -260,32 +280,18 @@ do { \ } action body_logic { - if (parser->flags & CHUNKED) { + if (parser->transfer_encoding == HTTP_CHUNKED) { fnext ChunkedBody; } else { - /* this is pretty stupid. i'd prefer to combine this with - * skip_chunk_data */ - if (parser->content_length < 0) { - /* If we didn't get a content length; if not keep-alive - * just read body until EOF */ - if (!http_parser_should_keep_alive(parser)) { - parser->flags |= EAT_FOREVER; - parser->chunk_size = REMAINING; - } else { - /* Otherwise, if keep-alive, then assume the message - * has no body. */ - parser->chunk_size = parser->content_length = 0; - } - } else { - parser->chunk_size = parser->content_length; - } - p += 1; + /* this is pretty stupid. i'd prefer to combine this with skip_chunk_data */ + parser->chunk_size = parser->content_length; + p += 1; - SKIP_BODY(MIN(REMAINING, parser->chunk_size)); + SKIP_BODY(MIN(REMAINING, parser->content_length)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } fhold; @@ -308,13 +314,13 @@ do { \ escape = ("%" xdigit xdigit); uchar = (unreserved | escape | "\""); pchar = (uchar | ":" | "@" | "&" | "=" | "+"); - tspecials = ("(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | "\"" + tspecials = ("(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | "\"" | "/" | "[" | "]" | "?" | "=" | "{" | "}" | " " | "\t"); # elements token = (ascii -- (CTL | tspecials)); quote = "\""; -# qdtext = token -- "\""; +# qdtext = token -- "\""; # quoted_pair = "\" ascii; # quoted_string = "\"" (qdtext | quoted_pair )* "\""; @@ -336,11 +342,7 @@ do { \ | "UNLOCK" %{ parser->method = HTTP_UNLOCK; } ); # Not allowing extension methods - HTTP_Version = "HTTP/" ( "1.1" %version_11 - | "1.0" %version_10 - | "0.9" %version_09 - | (digit "." digit) - ); + HTTP_Version = "HTTP/" digit $version_major "." digit $version_minor; scheme = ( alpha | digit | "+" | "-" | "." )* ; absolute_uri = (scheme ":" (uchar | reserved )*); @@ -362,12 +364,12 @@ do { \ hsep = ":" " "*; header = (field_name hsep field_value) :> CRLF; Header = ( ("Content-Length"i hsep digit+ $content_length) - | ("Connection"i hsep + | ("Connection"i hsep ( "Keep-Alive"i %set_keep_alive | "close"i %set_not_keep_alive ) ) - | ("Transfer-Encoding"i hsep "chunked"i %use_chunked_encoding) + | ("Transfer-Encoding"i %use_chunked_encoding hsep "identity" %use_identity_encoding) | (Field_Name hsep Field_Value) ) :> CRLF; @@ -385,11 +387,11 @@ do { \ chunk_ext_val = token*; chunk_ext_name = token*; chunk_extension = ( ";" " "* chunk_ext_name ("=" chunk_ext_val)? )*; - last_chunk = "0"+ ( chunk_extension | " "+) CRLF; - chunk_size = (xdigit* [1-9a-fA-F] xdigit* ) $add_to_chunk_size; + last_chunk = "0"+ chunk_extension CRLF; + chunk_size = (xdigit* [1-9a-fA-F] xdigit*) $add_to_chunk_size; chunk_end = CRLF; chunk_body = any >skip_chunk_data; - chunk_begin = chunk_size ( chunk_extension | " "+ ) CRLF; + chunk_begin = chunk_size chunk_extension CRLF; chunk = chunk_begin chunk_body chunk_end; ChunkedBody := chunk* last_chunk trailing_headers CRLF @end_chunked_body; @@ -413,12 +415,13 @@ do { \ %% write data; void -http_parser_init (http_parser *parser, enum http_parser_type type) +http_parser_init (http_parser *parser, enum http_parser_type type) { int cs = 0; %% write init; parser->cs = cs; parser->type = type; + parser->error = 0; parser->on_message_begin = NULL; parser->on_path = NULL; @@ -435,39 +438,23 @@ http_parser_init (http_parser *parser, enum http_parser_type type) } /** exec **/ -void +size_t http_parser_execute (http_parser *parser, const char *buffer, size_t len) { size_t tmp; // REMOVE ME this is extremely hacky int callback_return_value = 0; - const char *p, *pe, *eof; + const char *p, *pe; int cs = parser->cs; p = buffer; pe = buffer+len; - eof = len ? NULL : pe; - if (parser->flags & EAT_FOREVER) { - if (len == 0) { - if (parser->on_message_complete) { - callback_return_value = parser->on_message_complete(parser); - if (callback_return_value != 0) parser->flags |= ERROR; - } - } else { - if (parser->on_body) { - callback_return_value = parser->on_body(parser, p, len); - if (callback_return_value != 0) parser->flags |= ERROR; - } - } - return; - } - - if (0 < parser->chunk_size && (parser->flags & EATING)) { + if (0 < parser->chunk_size && parser->eating) { /* eat body */ SKIP_BODY(MIN(len, parser->chunk_size)); if (callback_return_value != 0) { - parser->flags |= ERROR; - return; + parser->error = TRUE; + return 0; } } @@ -490,11 +477,26 @@ http_parser_execute (http_parser *parser, const char *buffer, size_t len) CALLBACK(uri); assert(p <= pe && "buffer overflow after parsing execute"); + return(p - buffer); } int -http_parser_has_error (http_parser *parser) +http_parser_has_error (http_parser *parser) { - if (parser->flags & ERROR) return 1; + if (parser->error) return TRUE; return parser->cs == http_parser_error; } + +int +http_parser_should_keep_alive (http_parser *parser) +{ + if (parser->keep_alive == -1) + if (parser->version_major == 1) + return (parser->version_minor != 0); + else if (parser->version_major == 0) + return FALSE; + else + return TRUE; + else + return parser->keep_alive; +} diff --git a/deps/http_parser/test.c b/deps/http_parser/test.c index 58bc7df3b6..5405f639e0 100644 --- a/deps/http_parser/test.c +++ b/deps/http_parser/test.c @@ -38,7 +38,7 @@ struct message { static struct message messages[5]; static int num_messages; -/* * R E Q U E S T S * */ +/* * R E Q U E S T S * */ const struct message requests[] = #define CURL_GET 0 { {.name= "curl get" @@ -55,7 +55,7 @@ const struct message requests[] = ,.request_path= "/test" ,.request_uri= "/test" ,.num_headers= 3 - ,.headers= + ,.headers= { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" } , { "Host", "0.0.0.0=5000" } , { "Accept", "*/*" } @@ -83,7 +83,7 @@ const struct message requests[] = ,.request_path= "/favicon.ico" ,.request_uri= "/favicon.ico" ,.num_headers= 8 - ,.headers= + ,.headers= { { "Host", "0.0.0.0=5000" } , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" } , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } @@ -109,7 +109,7 @@ const struct message requests[] = ,.request_path= "/dumbfuck" ,.request_uri= "/dumbfuck" ,.num_headers= 1 - ,.headers= + ,.headers= { { "aaaaaaaaaaaaa", "++++++++++" } } ,.body= "" @@ -126,7 +126,7 @@ const struct message requests[] = ,.fragment= "posts-17408" ,.request_path= "/forums/1/topics/2375" /* XXX request uri does not include fragment? */ - ,.request_uri= "/forums/1/topics/2375?page=1" + ,.request_uri= "/forums/1/topics/2375?page=1" ,.num_headers= 0 ,.body= "" } @@ -159,7 +159,7 @@ const struct message requests[] = ,.request_path= "/get_one_header_no_body" ,.request_uri= "/get_one_header_no_body" ,.num_headers= 1 - ,.headers= + ,.headers= { { "Accept" , "*/*" } } ,.body= "" @@ -179,7 +179,7 @@ const struct message requests[] = ,.request_path= "/get_funky_content_length_body_hello" ,.request_uri= "/get_funky_content_length_body_hello" ,.num_headers= 1 - ,.headers= + ,.headers= { { "conTENT-Length" , "5" } } ,.body= "HELLO" @@ -201,10 +201,10 @@ const struct message requests[] = ,.request_path= "/post_identity_body_world" ,.request_uri= "/post_identity_body_world?q=search" ,.num_headers= 3 - ,.headers= + ,.headers= { { "Accept", "*/*" } , { "Transfer-Encoding", "identity" } - , { "Content-Length", "5" } + , { "Content-Length", "5" } } ,.body= "World" } @@ -225,7 +225,7 @@ const struct message requests[] = ,.request_path= "/post_chunked_all_your_base" ,.request_uri= "/post_chunked_all_your_base" ,.num_headers= 1 - ,.headers= + ,.headers= { { "Transfer-Encoding" , "chunked" } } ,.body= "all your base are belong to us" @@ -248,13 +248,13 @@ const struct message requests[] = ,.request_path= "/two_chunks_mult_zero_end" ,.request_uri= "/two_chunks_mult_zero_end" ,.num_headers= 1 - ,.headers= + ,.headers= { { "Transfer-Encoding", "chunked" } } ,.body= "hello world" } -#define CHUNKED_W_TRAILING_HEADERS 10 +#define CHUNKED_W_TRAILING_HEADERS 10 , {.name= "chunked with trailing headers. blech." ,.type= HTTP_REQUEST ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n" @@ -273,13 +273,13 @@ const struct message requests[] = ,.request_path= "/chunked_w_trailing_headers" ,.request_uri= "/chunked_w_trailing_headers" ,.num_headers= 1 - ,.headers= + ,.headers= { { "Transfer-Encoding", "chunked" } } ,.body= "hello world" } -#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 +#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 , {.name= "with bullshit after the length" ,.type= HTTP_REQUEST ,.raw= "POST /chunked_w_bullshit_after_length HTTP/1.1\r\n" @@ -296,7 +296,7 @@ const struct message requests[] = ,.request_path= "/chunked_w_bullshit_after_length" ,.request_uri= "/chunked_w_bullshit_after_length" ,.num_headers= 1 - ,.headers= + ,.headers= { { "Transfer-Encoding", "chunked" } } ,.body= "hello world" @@ -320,8 +320,8 @@ const struct message requests[] = , {.name= NULL } /* sentinel */ }; -/* * R E S P O N S E S * */ -const struct message responses[] = +/* * R E S P O N S E S * */ +const struct message responses[] = { {.name= "google 301" ,.type= HTTP_RESPONSE ,.raw= "HTTP/1.1 301 Moved Permanently\r\n" @@ -342,7 +342,7 @@ const struct message responses[] = ,.should_keep_alive= TRUE ,.status_code= 301 ,.num_headers= 7 - ,.headers= + ,.headers= { { "Location", "http://www.google.com/" } , { "Content-Type", "text/html; charset=UTF-8" } , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" } @@ -359,45 +359,6 @@ const struct message responses[] = "\r\n" } -, {.name= "no content-length response" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n" - "Server: Apache\r\n" - "X-Powered-By: Servlet/2.5 JSP/2.1\r\n" - "Content-Type: text/xml; charset=utf-8\r\n" - "Connection: close\r\n" - "\r\n" - "\n" - "\n" - " \n" - " \n" - " SOAP-ENV:Client\n" - " Client Error\n" - " \n" - " \n" - "" - ,.should_keep_alive= FALSE - ,.status_code= 200 - ,.num_headers= 5 - ,.headers= - { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" } - , { "Server", "Apache" } - , { "X-Powered-By", "Servlet/2.5 JSP/2.1" } - , { "Content-Type", "text/xml; charset=utf-8" } - , { "Connection", "close" } - } - ,.body= "\n" - "\n" - " \n" - " \n" - " SOAP-ENV:Client\n" - " Client Error\n" - " \n" - " \n" - "" - } - , {.name= "404 no headers no body" ,.type= HTTP_RESPONSE ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n" @@ -416,34 +377,7 @@ const struct message responses[] = ,.num_headers= 0 ,.headers= {} ,.body= "" - } - -, {.name="200 trailing space on chunked body" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Content-Type: text/plain\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "25 \r\n" - "This is the data in the first chunk\r\n" - "\r\n" - "1C\r\n" - "and this is the second one\r\n" - "\r\n" - "0 \r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.status_code= 200 - ,.num_headers= 2 - ,.headers= - { {"Content-Type", "text/plain" } - , {"Transfer-Encoding", "chunked" } - } - ,.body = - "This is the data in the first chunk\r\n" - "and this is the second one\r\n" - - } +} , {.name= NULL } /* sentinel */ }; @@ -609,14 +543,12 @@ parse_messages (int message_count, const struct message *input_messages[]) } // Parse the stream + size_t traversed = 0; parser_init(HTTP_REQUEST); - http_parser_execute(&parser, total, length); - assert(!http_parser_has_error(&parser)); + traversed = http_parser_execute(&parser, total, length); - http_parser_execute(&parser, NULL, 0); assert(!http_parser_has_error(&parser)); - assert(num_messages == message_count); for (i = 0; i < message_count; i++) { @@ -628,14 +560,11 @@ parse_messages (int message_count, const struct message *input_messages[]) void test_message (const struct message *message) { + size_t traversed = 0; parser_init(message->type); - http_parser_execute(&parser, message->raw, strlen(message->raw)); + traversed = http_parser_execute(&parser, message->raw, strlen(message->raw)); assert(!http_parser_has_error(&parser)); - - http_parser_execute(&parser, NULL, 0); - assert(!http_parser_has_error(&parser)); - assert(num_messages == 1); message_eq(0, message); @@ -644,10 +573,10 @@ test_message (const struct message *message) void test_error (const char *buf) { + size_t traversed = 0; parser_init(HTTP_REQUEST); - http_parser_execute(&parser, buf, strlen(buf)); - http_parser_execute(&parser, NULL, 0); + traversed = http_parser_execute(&parser, buf, strlen(buf)); assert(http_parser_has_error(&parser)); } @@ -655,32 +584,30 @@ test_error (const char *buf) void test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3) { - char total[ strlen(r1->raw) - + strlen(r2->raw) - + strlen(r3->raw) + char total[ strlen(r1->raw) + + strlen(r2->raw) + + strlen(r3->raw) + 1 ]; total[0] = '\0'; - strcat(total, r1->raw); - strcat(total, r2->raw); - strcat(total, r3->raw); + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); + size_t traversed = 0; parser_init(HTTP_REQUEST); - http_parser_execute(&parser, total, strlen(total)); - assert(!http_parser_has_error(&parser) ); - - http_parser_execute(&parser, NULL, 0); - assert(!http_parser_has_error(&parser) ); + traversed = http_parser_execute(&parser, total, strlen(total)); + assert(! http_parser_has_error(&parser) ); assert(num_messages == 3); message_eq(0, r1); message_eq(1, r2); message_eq(2, r3); } -/* SCAN through every possible breaking to make sure the +/* SCAN through every possible breaking to make sure the * parser can handle getting the content in any chunks that * might come from the socket */ @@ -692,13 +619,13 @@ test_scan (const struct message *r1, const struct message *r2, const struct mess char buf2[80*1024] = "\0"; char buf3[80*1024] = "\0"; - strcat(total, r1->raw); - strcat(total, r2->raw); - strcat(total, r3->raw); + strcat(total, r1->raw); + strcat(total, r2->raw); + strcat(total, r3->raw); int total_len = strlen(total); - int total_ops = (total_len - 1) * (total_len - 2) / 2; + int total_ops = (total_len - 1) * (total_len - 2) / 2; int ops = 0 ; int i,j; @@ -732,16 +659,16 @@ test_scan (const struct message *r1, const struct message *r2, const struct mess */ http_parser_execute(&parser, buf1, buf1_len); + assert(!http_parser_has_error(&parser)); http_parser_execute(&parser, buf2, buf2_len); + assert(!http_parser_has_error(&parser)); http_parser_execute(&parser, buf3, buf3_len); - assert(!http_parser_has_error(&parser)); - http_parser_execute(&parser, NULL, 0); - assert(!http_parser_has_error(&parser)); + assert(! http_parser_has_error(&parser)); assert(3 == num_messages); @@ -760,14 +687,14 @@ main (void) printf("sizeof(http_parser) = %d\n", sizeof(http_parser)); - int request_count; + int request_count; for (request_count = 0; requests[request_count].name; request_count++); - int response_count; + int response_count; for (response_count = 0; responses[response_count].name; response_count++); - //// RESPONSES + //// RESPONSES for (i = 0; i < response_count; i++) { test_message(&responses[i]); @@ -828,7 +755,7 @@ main (void) "Accept: */*\r\n" "\r\n" "HELLO"; - test_error(bad_get_no_headers_no_body); + test_error(bad_get_no_headers_no_body); /* TODO sending junk and large headers gets rejected */ diff --git a/lib/http.js b/lib/http.js index c904979d8a..04f2a13b95 100644 --- a/lib/http.js +++ b/lib/http.js @@ -336,7 +336,7 @@ function ClientRequest (method, uri, headers) { } this.closeOnFinish = true; - this.sendHeaderLines(method + " " + uri + " HTTP/1.0\r\n", headers); + this.sendHeaderLines(method + " " + uri + " HTTP/1.1\r\n", headers); } process.inherits(ClientRequest, OutgoingMessage); exports.ClientRequest = ClientRequest; @@ -480,6 +480,7 @@ function connectionListener (connection) { } }); + createIncomingMessageStream(connection, function (incoming, should_keep_alive) { var req = incoming; @@ -510,9 +511,7 @@ exports.createClient = function (port, host) { return; } //sys.debug("client flush readyState = " + client.readyState); - if (req == requests[0]) { - if(flushMessageQueue(client, [req])) client.close(); - } + if (req == requests[0]) flushMessageQueue(client, [req]); }); requests.push(req); }; diff --git a/src/node_http.cc b/src/node_http.cc index b139796d09..46bb6b4d34 100644 --- a/src/node_http.cc +++ b/src/node_http.cc @@ -64,21 +64,6 @@ HTTPConnection::OnReceive (const void *buf, size_t len) if (http_parser_has_error(&parser_)) ForceClose(); } -void -HTTPConnection::OnEOF () -{ - HandleScope scope; - - assert(attached_); - http_parser_execute(&parser_, NULL, 0); - - if (http_parser_has_error(&parser_)) { - ForceClose(); - } else { - Emit("eof", 0, NULL); - } -} - int HTTPConnection::on_message_begin (http_parser *parser) { @@ -224,25 +209,14 @@ HTTPConnection::on_headers_complete (http_parser *parser) Integer::New(connection->parser_.status_code)); // VERSION - Local version; - switch (connection->parser_.version) { - case HTTP_VERSION_OTHER: - version = String::NewSymbol("Other"); - break; - - case HTTP_VERSION_09: - version = String::NewSymbol("0.9"); - break; - - case HTTP_VERSION_10: - version = String::NewSymbol("1.0"); - break; - - case HTTP_VERSION_11: - version = String::NewSymbol("1.1"); - break; - } - message_info->Set(HTTP_VERSION_SYMBOL, version); + char version[10]; + snprintf( version + , 10 + , "%d.%d" + , connection->parser_.version_major + , connection->parser_.version_minor + ); + message_info->Set(HTTP_VERSION_SYMBOL, String::New(version)); message_info->Set(SHOULD_KEEP_ALIVE_SYMBOL, http_parser_should_keep_alive(&connection->parser_) ? True() : False()); diff --git a/src/node_http.h b/src/node_http.h index cf70c12377..a66b881682 100644 --- a/src/node_http.h +++ b/src/node_http.h @@ -36,7 +36,6 @@ protected: } void OnReceive (const void *buf, size_t len); - void OnEOF (); static int on_message_begin (http_parser *parser); static int on_uri (http_parser *parser, const char *at, size_t length); diff --git a/test/mjsunit/test-http-malformed-request.js b/test/mjsunit/test-http-malformed-request.js index e9c8fc576d..ea492fa3ed 100644 --- a/test/mjsunit/test-http-malformed-request.js +++ b/test/mjsunit/test-http-malformed-request.js @@ -7,30 +7,26 @@ http = require("http"); port = 9999; nrequests_completed = 0; -nrequests_expected = 2; +nrequests_expected = 1; -var server = http.createServer(function (req, res) { +var s = http.createServer(function (req, res) { puts("req: " + JSON.stringify(req.uri)); res.sendHeader(200, {"Content-Type": "text/plain"}); res.sendBody("Hello World"); res.finish(); - if (++nrequests_completed == nrequests_expected) server.close(); - - puts("nrequests_completed: " + nrequests_completed); + if (++nrequests_completed == nrequests_expected) s.close(); }); -server.listen(port); +s.listen(port); -tcp.createConnection(port).addListener("connect", function () { - this.send("GET /hello?foo=%99bar HTTP/1.1\r\nConnection: close\r\n\r\n"); - this.close(); +var c = tcp.createConnection(port); +c.addListener("connect", function () { + c.send("GET /hello?foo=%99bar HTTP/1.1\r\n\r\n"); + c.close(); }); -tcp.createConnection(port).addListener("connect", function () { - this.send("GET /with_\"stupid\"_quotes?in_the=\"uri\" HTTP/1.1\r\nConnection: close\r\n\r\n"); - this.close(); -}); +// TODO add more! process.addListener("exit", function () { assertEquals(nrequests_expected, nrequests_completed); diff --git a/test/mjsunit/test-http-proxy.js b/test/mjsunit/test-http-proxy.js index e9ffde70a5..5bd940bbe9 100644 --- a/test/mjsunit/test-http-proxy.js +++ b/test/mjsunit/test-http-proxy.js @@ -5,12 +5,12 @@ var PROXY_PORT = 8869; var BACKEND_PORT = 8870; var backend = http.createServer(function (req, res) { - debug("backend"); + // debug("backend"); res.sendHeader(200, {"content-type": "text/plain"}); res.sendBody("hello world\n"); res.finish(); }); -debug("listen backend") +// debug("listen backend") backend.listen(BACKEND_PORT); var proxy_client = http.createClient(BACKEND_PORT); @@ -24,30 +24,30 @@ var proxy = http.createServer(function (req, res) { }); proxy_res.addListener("complete", function() { res.finish(); - debug("proxy res"); + // debug("proxy res"); }); }); }); -debug("listen proxy") +// debug("listen proxy") proxy.listen(PROXY_PORT); var body = ""; var client = http.createClient(PROXY_PORT); var req = client.get("/test"); -debug("client req") +// debug("client req") req.finish(function (res) { - debug("got res: " + JSON.stringify(res.headers)); + // debug("got res"); assertEquals(200, res.statusCode); res.setBodyEncoding("utf8"); res.addListener("body", function (chunk) { body += chunk; }); res.addListener("complete", function () { proxy.close(); backend.close(); - debug("closed both"); + // debug("closed both"); }); }); process.addListener("exit", function () { - assertEquals("hello world\n", body); + assertEquals(body, "hello world\n"); }); diff --git a/test/mjsunit/test-http-server.js b/test/mjsunit/test-http-server.js index 4dda11169c..022aa566f0 100644 --- a/test/mjsunit/test-http-server.js +++ b/test/mjsunit/test-http-server.js @@ -13,12 +13,6 @@ http.createServer(function (req, res) { res.id = request_number; req.id = request_number++; - puts("server got request " + req.id); - - req.addListener("complete", function () { - puts("request complete " + req.id); - }); - if (req.id == 0) { assertEquals("GET", req.method); assertEquals("/hello", req.uri.path); @@ -30,11 +24,10 @@ http.createServer(function (req, res) { assertEquals("POST", req.method); assertEquals("/quit", req.uri.path); this.close(); - puts("server closed"); + //puts("server closed"); } setTimeout(function () { - puts("send response " + req.id); res.sendHeader(200, {"Content-Type": "text/plain"}); res.sendBody(req.uri.path); res.finish(); @@ -47,8 +40,7 @@ var c = tcp.createConnection(port); c.setEncoding("utf8"); c.addListener("connect", function () { - puts("client connected. sending first request"); - c.send("GET /hello?hello=world&foo=b==ar HTTP/1.1\r\n\r\n" ); + c.send( "GET /hello?hello=world&foo=b==ar HTTP/1.1\r\n\r\n" ); requests_sent += 1; }); @@ -56,9 +48,7 @@ c.addListener("receive", function (chunk) { server_response += chunk; if (requests_sent == 1) { - puts("send request 2"); c.send("POST /quit HTTP/1.1\r\n\r\n"); - puts("close client"); c.close(); assertEquals(c.readyState, "readOnly"); requests_sent += 1; @@ -66,12 +56,10 @@ c.addListener("receive", function (chunk) { }); c.addListener("eof", function () { - puts("client got eof"); client_got_eof = true; }); c.addListener("close", function () { - puts("client closed"); assertEquals(c.readyState, "closed"); });