diff --git a/deps/http_parser/README.md b/deps/http_parser/README.md index e0c2b9ce15..d60473ef1b 100644 --- a/deps/http_parser/README.md +++ b/deps/http_parser/README.md @@ -52,13 +52,6 @@ When data is received on the socket execute the parser and check for errors. // handle error. usually just close the connection } -During the `http_parser_execute()` call, the callbacks set in `http_parser` -will be executed. The parser maintains state and never looks behind, so -buffering the data is not necessary. If you need to save certain data for -later usage, you can do that from the callbacks. (You can also `read()` into -a heap allocated buffer to avoid copying memory around if this fits your -application.) - 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 @@ -74,9 +67,65 @@ need to inspect the body. Decoding gzip is non-neglagable amount of processing (and requires making allocations). HTTP proxies using this parser, for example, would not want such a feature. +Callbacks +--------- + +During the `http_parser_execute()` call, the callbacks set in `http_parser` +will be executed. The parser maintains state and never looks behind, so +buffering the data is not necessary. If you need to save certain data for +later usage, you can do that from the callbacks. + +There are two types of callbacks: + +* notification `typedef int (*http_cb) (http_parser*);` + Callbacks: on_message_begin, on_headers_complete, on_message_complete. +* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);` + Callbacks: (requests only) on_path, on_query_string, on_uri, on_fragment, + (common) on_header_field, on_header_value, on_body; + +In case you parse HTTP message in chunks (i.e. `read()` request line +from socket, parse, read half headers, parse, etc) your data callbacks +may be called more than once. Http-parser guarantees that data pointer is only +valid for the lifetime of callback. You can also `read()` into a heap allocated +buffer to avoid copying memory around if this fits your application. + +Reading headers may be a tricky task if you read/parse headers partially. +Basically, you need to remember whether last header callback was field or value +and apply following logic: + + /* on_header_field and on_header_value shortened to on_h_* + ------------------------ ------------ -------------------------------------------- + | State (prev. callback) | Callback | Description/action | + ------------------------ ------------ -------------------------------------------- + | nothing (first call) | on_h_field | Allocate new buffer and copy callback data | + | | | into it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_field | New header started. | + | | | Copy current name,value buffers to headers | + | | | list and allocate new buffer for new name | + ------------------------ ------------ -------------------------------------------- + | field | on_h_field | Previous name continues. Reallocate name | + | | | buffer and append callback data to it | + ------------------------ ------------ -------------------------------------------- + | field | on_h_value | Value for current header started. Allocate | + | | | new buffer and copy callback data to it | + ------------------------ ------------ -------------------------------------------- + | value | on_h_value | Value continues. Reallocate value buffer | + | | | and append callback data to it | + ------------------------ ------------ -------------------------------------------- + */ + +See examples of reading in headers: + +* [partial example](http://gist.github.com/155877) in C +* [from http-parser tests](http://github.com/ry/http-parser/blob/37a0ff8928fb0d83cec0d0d8909c5a4abcd221af/test.c#L403) in C +* [from Node library](http://github.com/ry/node/blob/842eaf446d2fdcb33b296c67c911c32a0dabc747/src/http.js#L284) in Javascript + Releases -------- + * [0.2](http://s3.amazonaws.com/four.livejournal/20090807/http_parser-0.2.tar.gz) + * [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). diff --git a/deps/http_parser/http_parser.c b/deps/http_parser/http_parser.c index 13254824b6..071b81753e 100644 --- a/deps/http_parser/http_parser.c +++ b/deps/http_parser/http_parser.c @@ -114,13 +114,13 @@ do { \ #line 116 "http_parser.c" static const int http_parser_start = 1; -static const int http_parser_first_final = 267; +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 = 12; -static const int http_parser_en_Requests = 269; -static const int http_parser_en_Responses = 270; +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 416 "http_parser.rl" @@ -143,6 +143,7 @@ http_parser_init (http_parser *parser, enum http_parser_type type) parser->on_path = NULL; parser->on_query_string = NULL; parser->on_uri = NULL; + parser->on_fragment = NULL; parser->on_header_field = NULL; parser->on_header_value = NULL; parser->on_headers_complete = NULL; @@ -181,7 +182,7 @@ http_parser_execute (http_parser *parser, const char *buffer, size_t len) if (parser->uri_mark) parser->uri_mark = buffer; -#line 185 "http_parser.c" +#line 186 "http_parser.c" { if ( p == pe ) goto _test_eof; @@ -190,14 +191,14 @@ http_parser_execute (http_parser *parser, const char *buffer, size_t len) _again: switch ( cs ) { case 1: goto st1; - case 267: goto st267; + 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 268: goto st268; + case 267: goto st267; case 7: goto st7; case 8: goto st8; case 9: goto st9; @@ -211,7 +212,7 @@ _again: case 17: goto st17; case 18: goto st18; case 19: goto st19; - case 269: goto st269; + case 268: goto st268; case 20: goto st20; case 21: goto st21; case 22: goto st22; @@ -374,7 +375,7 @@ _again: case 179: goto st179; case 180: goto st180; case 181: goto st181; - case 270: goto st270; + case 269: goto st269; case 182: goto st182; case 183: goto st183; case 184: goto st184; @@ -459,7 +460,6 @@ _again: case 263: goto st263; case 264: goto st264; case 265: goto st265; - case 266: goto st266; default: break; } @@ -478,16 +478,16 @@ tr0: { p--; if (parser->type == HTTP_REQUEST) { - {goto st269;} + {goto st268;} } else { - {goto st270;} + {goto st269;} } } - goto st267; -st267: + goto st266; +st266: if ( ++p == pe ) - goto _test_eof267; -case 267: + goto _test_eof266; +case 266: #line 492 "http_parser.c" goto st0; st0: @@ -577,21 +577,21 @@ case 6: goto tr9; goto st0; tr9: - cs = 268; + cs = 267; #line 273 "http_parser.rl" { END_REQUEST; if (parser->type == HTTP_REQUEST) { - cs = 269; + cs = 268; } else { - cs = 270; + cs = 269; } } goto _again; -st268: +st267: if ( ++p == pe ) - goto _test_eof268; -case 268: + goto _test_eof267; +case 267: #line 596 "http_parser.c" goto st0; st7: @@ -879,7 +879,7 @@ case 19: goto st19; goto st0; tr45: - cs = 269; + cs = 268; #line 203 "http_parser.rl" { if(parser->on_headers_complete) { @@ -913,25 +913,25 @@ tr45: } } goto _again; -st269: +st268: if ( ++p == pe ) - goto _test_eof269; -case 269: + goto _test_eof268; +case 268: #line 921 "http_parser.c" switch( (*p) ) { - case 67: goto tr311; - case 68: goto tr312; - case 71: goto tr313; - case 72: goto tr314; - case 76: goto tr315; - case 77: goto tr316; - case 79: goto tr317; - case 80: goto tr318; - case 84: goto tr319; - case 85: goto tr320; + 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; -tr311: +tr310: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3324,7 +3324,7 @@ case 120: } else goto st118; goto st0; -tr312: +tr311: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3379,7 +3379,7 @@ case 126: if ( (*p) == 32 ) goto tr154; goto st0; -tr313: +tr312: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3413,7 +3413,7 @@ case 129: if ( (*p) == 32 ) goto tr157; goto st0; -tr314: +tr313: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3454,7 +3454,7 @@ case 133: if ( (*p) == 32 ) goto tr161; goto st0; -tr315: +tr314: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3495,7 +3495,7 @@ case 137: if ( (*p) == 32 ) goto tr165; goto st0; -tr316: +tr315: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3566,7 +3566,7 @@ case 145: if ( (*p) == 32 ) goto tr174; goto st0; -tr317: +tr316: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3628,7 +3628,7 @@ case 152: if ( (*p) == 32 ) goto tr181; goto st0; -tr318: +tr317: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3772,7 +3772,7 @@ case 170: if ( (*p) == 32 ) goto tr202; goto st0; -tr319: +tr318: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3820,7 +3820,7 @@ case 175: if ( (*p) == 32 ) goto tr207; goto st0; -tr320: +tr319: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -3875,8 +3875,8 @@ case 181: if ( (*p) == 32 ) goto tr213; goto st0; -tr233: - cs = 270; +tr232: + cs = 269; #line 203 "http_parser.rl" { if(parser->on_headers_complete) { @@ -3910,15 +3910,15 @@ tr233: } } goto _again; -st270: +st269: if ( ++p == pe ) - goto _test_eof270; -case 270: + goto _test_eof269; +case 269: #line 3918 "http_parser.c" if ( (*p) == 72 ) - goto tr321; + goto tr320; goto st0; -tr321: +tr320: #line 213 "http_parser.rl" { if(parser->on_message_begin) { @@ -4052,35 +4052,12 @@ st193: goto _test_eof193; case 193: #line 4055 "http_parser.c" - if ( (*p) == 32 ) - goto st194; - goto st0; -st194: - if ( ++p == pe ) - goto _test_eof194; -case 194: - if ( (*p) < 11 ) { - if ( 0 <= (*p) && (*p) <= 9 ) - goto st195; - } else if ( (*p) > 12 ) { - if ( 14 <= (*p) ) - goto st195; - } else - goto st195; - goto st0; -st195: - if ( ++p == pe ) - goto _test_eof195; -case 195: - if ( (*p) == 13 ) - goto st196; - if ( (*p) > 9 ) { - if ( 11 <= (*p) ) - goto st195; - } else if ( (*p) >= 0 ) - goto st195; + switch( (*p) ) { + case 13: goto st194; + case 32: goto st265; + } goto st0; -tr237: +tr236: #line 118 "http_parser.rl" { parser->header_value_mark = p; @@ -4096,8 +4073,8 @@ tr237: parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st196; -tr240: + goto st194; +tr239: #line 153 "http_parser.rl" { CALLBACK(header_value); @@ -4108,8 +4085,8 @@ tr240: parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st196; -tr259: + goto st194; +tr258: #line 241 "http_parser.rl" { parser->keep_alive = FALSE; } #line 153 "http_parser.rl" @@ -4122,8 +4099,8 @@ tr259: parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st196; -tr269: + goto st194; +tr268: #line 240 "http_parser.rl" { parser->keep_alive = TRUE; } #line 153 "http_parser.rl" @@ -4136,8 +4113,8 @@ tr269: parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st196; -tr310: + goto st194; +tr309: #line 237 "http_parser.rl" { parser->transfer_encoding = HTTP_IDENTITY; } #line 153 "http_parser.rl" @@ -4150,91 +4127,91 @@ tr310: parser->header_value_mark = NULL; parser->header_value_size = 0; } - goto st196; -st196: + goto st194; +st194: if ( ++p == pe ) - goto _test_eof196; -case 196: -#line 4159 "http_parser.c" + goto _test_eof194; +case 194: +#line 4136 "http_parser.c" if ( (*p) == 10 ) - goto st197; + goto st195; goto st0; -st197: +st195: if ( ++p == pe ) - goto _test_eof197; -case 197: + goto _test_eof195; +case 195: switch( (*p) ) { - case 13: goto st198; - case 33: goto tr230; - case 67: goto tr231; - case 84: goto tr232; - case 99: goto tr231; - case 116: goto tr232; - case 124: goto tr230; - case 126: goto tr230; + 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 tr230; + goto tr229; } else if ( (*p) >= 35 ) - goto tr230; + goto tr229; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto tr230; + goto tr229; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto tr230; + goto tr229; } else - goto tr230; + goto tr229; } else - goto tr230; + goto tr229; goto st0; -st198: +st196: if ( ++p == pe ) - goto _test_eof198; -case 198: + goto _test_eof196; +case 196: if ( (*p) == 10 ) - goto tr233; + goto tr232; goto st0; -tr230: +tr229: #line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st199; -st199: + goto st197; +st197: if ( ++p == pe ) - goto _test_eof199; -case 199: -#line 4213 "http_parser.c" + goto _test_eof197; +case 197: +#line 4190 "http_parser.c" switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -tr235: +tr234: #line 143 "http_parser.rl" { CALLBACK(header_field); @@ -4245,341 +4222,341 @@ tr235: parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st200; -st200: + goto st198; +st198: if ( ++p == pe ) - goto _test_eof200; -case 200: -#line 4254 "http_parser.c" + goto _test_eof198; +case 198: +#line 4231 "http_parser.c" switch( (*p) ) { - case 13: goto tr237; - case 32: goto st200; + case 13: goto tr236; + case 32: goto st198; } - goto tr236; -tr236: + goto tr235; +tr235: #line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st201; -st201: + goto st199; +st199: if ( ++p == pe ) - goto _test_eof201; -case 201: -#line 4271 "http_parser.c" + goto _test_eof199; +case 199: +#line 4248 "http_parser.c" if ( (*p) == 13 ) - goto tr240; - goto st201; -tr231: + goto tr239; + goto st199; +tr230: #line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st202; -st202: + goto st200; +st200: if ( ++p == pe ) - goto _test_eof202; -case 202: -#line 4286 "http_parser.c" + goto _test_eof200; +case 200: +#line 4263 "http_parser.c" switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 79: goto st203; - case 111: goto st203; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st203: +st201: if ( ++p == pe ) - goto _test_eof203; -case 203: + goto _test_eof201; +case 201: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st204; - case 110: goto st204; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st204: +st202: if ( ++p == pe ) - goto _test_eof204; -case 204: + goto _test_eof202; +case 202: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st205; - case 84: goto st228; - case 110: goto st205; - case 116: goto st228; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st205: +st203: if ( ++p == pe ) - goto _test_eof205; -case 205: + goto _test_eof203; +case 203: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 69: goto st206; - case 101: goto st206; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st206: +st204: if ( ++p == pe ) - goto _test_eof206; -case 206: + goto _test_eof204; +case 204: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 67: goto st207; - case 99: goto st207; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st207: +st205: if ( ++p == pe ) - goto _test_eof207; -case 207: + goto _test_eof205; +case 205: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 84: goto st208; - case 116: goto st208; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st208: +st206: if ( ++p == pe ) - goto _test_eof208; -case 208: + goto _test_eof206; +case 206: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 73: goto st209; - case 105: goto st209; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st209: +st207: if ( ++p == pe ) - goto _test_eof209; -case 209: + goto _test_eof207; +case 207: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 79: goto st210; - case 111: goto st210; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st210: +st208: if ( ++p == pe ) - goto _test_eof210; -case 210: + goto _test_eof208; +case 208: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st211; - case 110: goto st211; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st211: +st209: if ( ++p == pe ) - goto _test_eof211; -case 211: + goto _test_eof209; +case 209: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr251; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -tr251: +tr250: #line 143 "http_parser.rl" { CALLBACK(header_field); @@ -4590,506 +4567,506 @@ tr251: parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st212; -st212: + goto st210; +st210: if ( ++p == pe ) - goto _test_eof212; -case 212: -#line 4599 "http_parser.c" + goto _test_eof210; +case 210: +#line 4576 "http_parser.c" switch( (*p) ) { - case 13: goto tr237; - case 32: goto st212; - case 67: goto tr253; - case 75: goto tr254; - case 99: goto tr253; - case 107: goto tr254; + 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 tr236; -tr253: + goto tr235; +tr252: #line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st213; + goto st211; +st211: + if ( ++p == pe ) + goto _test_eof211; +case 211: +#line 4597 "http_parser.c" + switch( (*p) ) { + case 13: goto tr239; + case 76: goto st212; + case 108: goto st212; + } + goto st199; +st212: + if ( ++p == pe ) + goto _test_eof212; +case 212: + switch( (*p) ) { + case 13: goto tr239; + case 79: goto st213; + case 111: goto st213; + } + goto st199; st213: if ( ++p == pe ) goto _test_eof213; case 213: -#line 4620 "http_parser.c" switch( (*p) ) { - case 13: goto tr240; - case 76: goto st214; - case 108: goto st214; + case 13: goto tr239; + case 83: goto st214; + case 115: goto st214; } - goto st201; + goto st199; st214: if ( ++p == pe ) goto _test_eof214; case 214: switch( (*p) ) { - case 13: goto tr240; - case 79: goto st215; - case 111: goto st215; + case 13: goto tr239; + case 69: goto st215; + case 101: goto st215; } - goto st201; + goto st199; st215: if ( ++p == pe ) goto _test_eof215; case 215: - switch( (*p) ) { - case 13: goto tr240; - case 83: goto st216; - case 115: goto st216; - } - goto st201; + if ( (*p) == 13 ) + goto tr258; + goto st199; +tr253: +#line 118 "http_parser.rl" + { + parser->header_value_mark = p; + parser->header_value_size = 0; + } + goto st216; st216: if ( ++p == pe ) goto _test_eof216; case 216: +#line 4652 "http_parser.c" switch( (*p) ) { - case 13: goto tr240; + case 13: goto tr239; case 69: goto st217; case 101: goto st217; } - goto st201; + goto st199; st217: if ( ++p == pe ) goto _test_eof217; case 217: - if ( (*p) == 13 ) - goto tr259; - goto st201; -tr254: -#line 118 "http_parser.rl" - { - parser->header_value_mark = p; - parser->header_value_size = 0; - } - goto st218; + switch( (*p) ) { + case 13: goto tr239; + case 69: goto st218; + case 101: goto st218; + } + goto st199; st218: if ( ++p == pe ) goto _test_eof218; case 218: -#line 4675 "http_parser.c" switch( (*p) ) { - case 13: goto tr240; - case 69: goto st219; - case 101: goto st219; + case 13: goto tr239; + case 80: goto st219; + case 112: goto st219; } - goto st201; + goto st199; st219: if ( ++p == pe ) goto _test_eof219; case 219: switch( (*p) ) { - case 13: goto tr240; - case 69: goto st220; - case 101: goto st220; + case 13: goto tr239; + case 45: goto st220; } - goto st201; + goto st199; st220: if ( ++p == pe ) goto _test_eof220; case 220: switch( (*p) ) { - case 13: goto tr240; - case 80: goto st221; - case 112: goto st221; + case 13: goto tr239; + case 65: goto st221; + case 97: goto st221; } - goto st201; + goto st199; st221: if ( ++p == pe ) goto _test_eof221; case 221: switch( (*p) ) { - case 13: goto tr240; - case 45: goto st222; + case 13: goto tr239; + case 76: goto st222; + case 108: goto st222; } - goto st201; + goto st199; st222: if ( ++p == pe ) goto _test_eof222; case 222: switch( (*p) ) { - case 13: goto tr240; - case 65: goto st223; - case 97: goto st223; + case 13: goto tr239; + case 73: goto st223; + case 105: goto st223; } - goto st201; + goto st199; st223: if ( ++p == pe ) goto _test_eof223; case 223: switch( (*p) ) { - case 13: goto tr240; - case 76: goto st224; - case 108: goto st224; + case 13: goto tr239; + case 86: goto st224; + case 118: goto st224; } - goto st201; + goto st199; st224: if ( ++p == pe ) goto _test_eof224; case 224: switch( (*p) ) { - case 13: goto tr240; - case 73: goto st225; - case 105: goto st225; + case 13: goto tr239; + case 69: goto st225; + case 101: goto st225; } - goto st201; + goto st199; st225: if ( ++p == pe ) goto _test_eof225; case 225: - switch( (*p) ) { - case 13: goto tr240; - case 86: goto st226; - case 118: goto st226; - } - goto st201; + if ( (*p) == 13 ) + goto tr268; + goto st199; st226: if ( ++p == pe ) goto _test_eof226; case 226: switch( (*p) ) { - case 13: goto tr240; + case 33: goto st197; + case 58: goto tr234; case 69: goto st227; case 101: goto st227; - } - goto st201; -st227: - if ( ++p == pe ) - goto _test_eof227; -case 227: - if ( (*p) == 13 ) - goto tr269; - goto st201; -st228: - if ( ++p == pe ) - goto _test_eof228; -case 228: - switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 69: goto st229; - case 101: goto st229; - case 124: goto st199; - case 126: goto st199; + case 124: goto st197; + case 126: goto st197; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st229: +st227: if ( ++p == pe ) - goto _test_eof229; -case 229: + goto _test_eof227; +case 227: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st230; - case 110: goto st230; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st230: +st228: if ( ++p == pe ) - goto _test_eof230; -case 230: + goto _test_eof228; +case 228: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 84: goto st231; - case 116: goto st231; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st231: +st229: if ( ++p == pe ) - goto _test_eof231; -case 231: + goto _test_eof229; +case 229: switch( (*p) ) { - case 33: goto st199; - case 45: goto st232; - case 46: goto st199; - case 58: goto tr235; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else if ( (*p) >= 65 ) - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st232: +st230: if ( ++p == pe ) - goto _test_eof232; -case 232: + goto _test_eof230; +case 230: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 76: goto st233; - case 108: goto st233; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st233: +st231: if ( ++p == pe ) - goto _test_eof233; -case 233: + goto _test_eof231; +case 231: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 69: goto st234; - case 101: goto st234; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st234: +st232: if ( ++p == pe ) - goto _test_eof234; -case 234: + goto _test_eof232; +case 232: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st235; - case 110: goto st235; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st235: +st233: if ( ++p == pe ) - goto _test_eof235; -case 235: + goto _test_eof233; +case 233: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 71: goto st236; - case 103: goto st236; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st236: +st234: if ( ++p == pe ) - goto _test_eof236; -case 236: + goto _test_eof234; +case 234: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 84: goto st237; - case 116: goto st237; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st237: +st235: if ( ++p == pe ) - goto _test_eof237; -case 237: + goto _test_eof235; +case 235: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 72: goto st238; - case 104: goto st238; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -st238: +st236: if ( ++p == pe ) - goto _test_eof238; -case 238: + goto _test_eof236; +case 236: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr280; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; -tr280: +tr279: #line 143 "http_parser.rl" { CALLBACK(header_field); @@ -5100,20 +5077,20 @@ tr280: parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st239; -st239: + goto st237; +st237: if ( ++p == pe ) - goto _test_eof239; -case 239: -#line 5109 "http_parser.c" + goto _test_eof237; +case 237: +#line 5086 "http_parser.c" switch( (*p) ) { - case 13: goto tr237; - case 32: goto st239; + case 13: goto tr236; + case 32: goto st237; } if ( 48 <= (*p) && (*p) <= 57 ) - goto tr282; - goto tr236; -tr282: + goto tr281; + goto tr235; +tr281: #line 223 "http_parser.rl" { if (parser->content_length > INT_MAX) { @@ -5128,8 +5105,8 @@ tr282: parser->header_value_mark = p; parser->header_value_size = 0; } - goto st240; -tr283: + goto st238; +tr282: #line 223 "http_parser.rl" { if (parser->content_length > INT_MAX) { @@ -5139,531 +5116,531 @@ tr283: parser->content_length *= 10; parser->content_length += *p - '0'; } - goto st240; -st240: + goto st238; +st238: if ( ++p == pe ) - goto _test_eof240; -case 240: -#line 5148 "http_parser.c" + goto _test_eof238; +case 238: +#line 5125 "http_parser.c" if ( (*p) == 13 ) - goto tr240; + goto tr239; if ( 48 <= (*p) && (*p) <= 57 ) - goto tr283; - goto st201; -tr232: + goto tr282; + goto st199; +tr231: #line 113 "http_parser.rl" { parser->header_field_mark = p; parser->header_field_size = 0; } - goto st241; + goto st239; +st239: + if ( ++p == pe ) + goto _test_eof239; +case 239: +#line 5142 "http_parser.c" + switch( (*p) ) { + 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 st197; + } else if ( (*p) >= 35 ) + goto st197; + } else if ( (*p) > 46 ) { + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st197; + } else if ( (*p) > 90 ) { + if ( 94 <= (*p) && (*p) <= 122 ) + goto st197; + } else + goto st197; + } else + goto st197; + goto st0; +st240: + if ( ++p == pe ) + goto _test_eof240; +case 240: + switch( (*p) ) { + 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 st197; + } else if ( (*p) >= 35 ) + goto st197; + } else if ( (*p) > 46 ) { + if ( (*p) < 66 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st197; + } else if ( (*p) > 90 ) { + if ( 94 <= (*p) && (*p) <= 122 ) + goto st197; + } else + goto st197; + } else + goto st197; + goto st0; st241: if ( ++p == pe ) goto _test_eof241; case 241: -#line 5165 "http_parser.c" switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 82: goto st242; - case 114: goto st242; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st242: if ( ++p == pe ) goto _test_eof242; case 242: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 65: goto st243; - case 97: goto st243; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { - if ( (*p) < 66 ) { + if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st243: if ( ++p == pe ) goto _test_eof243; case 243: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st244; - case 110: goto st244; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st244: if ( ++p == pe ) goto _test_eof244; case 244: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 83: goto st245; - case 115: goto st245; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st245: if ( ++p == pe ) goto _test_eof245; case 245: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 70: goto st246; - case 102: goto st246; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st246: if ( ++p == pe ) goto _test_eof246; case 246: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 69: goto st247; - case 101: goto st247; - case 124: goto st199; - case 126: goto st199; + 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) < 45 ) { + if ( (*p) < 48 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; - } else if ( (*p) > 46 ) { - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; - } else if ( (*p) > 90 ) { + goto st197; + } else if ( (*p) > 57 ) { + if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; - } else - goto st199; + goto st197; + } else if ( (*p) >= 65 ) + goto st197; } else - goto st199; + goto st197; goto st0; st247: if ( ++p == pe ) goto _test_eof247; case 247: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 82: goto st248; - case 114: goto st248; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st248: if ( ++p == pe ) goto _test_eof248; case 248: switch( (*p) ) { - case 33: goto st199; - case 45: goto st249; - case 46: goto st199; - case 58: goto tr235; - case 124: goto st199; - case 126: goto st199; + 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) < 48 ) { + if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) - goto st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; - } else if ( (*p) > 57 ) { - if ( (*p) > 90 ) { + goto st197; + } else if ( (*p) > 46 ) { + if ( (*p) < 65 ) { + if ( 48 <= (*p) && (*p) <= 57 ) + goto st197; + } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; - } else if ( (*p) >= 65 ) - goto st199; + goto st197; + } else + goto st197; } else - goto st199; + goto st197; goto st0; st249: if ( ++p == pe ) goto _test_eof249; case 249: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 69: goto st250; - case 101: goto st250; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st250: if ( ++p == pe ) goto _test_eof250; case 250: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st251; - case 110: goto st251; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st251: if ( ++p == pe ) goto _test_eof251; case 251: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 67: goto st252; - case 99: goto st252; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st252: if ( ++p == pe ) goto _test_eof252; case 252: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 79: goto st253; - case 111: goto st253; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st253: if ( ++p == pe ) goto _test_eof253; case 253: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 68: goto st254; - case 100: goto st254; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st254: if ( ++p == pe ) goto _test_eof254; case 254: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 73: goto st255; - case 105: goto st255; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; + goto st197; goto st0; st255: if ( ++p == pe ) goto _test_eof255; case 255: switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 78: goto st256; - case 110: goto st256; - case 124: goto st199; - case 126: goto st199; + 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 st199; + goto st197; } else if ( (*p) >= 35 ) - goto st199; + goto st197; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; + goto st197; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; + goto st197; } else - goto st199; + goto st197; } else - goto st199; - goto st0; -st256: - if ( ++p == pe ) - goto _test_eof256; -case 256: - switch( (*p) ) { - case 33: goto st199; - case 58: goto tr235; - case 71: goto st257; - case 103: goto st257; - case 124: goto st199; - case 126: goto st199; - } - if ( (*p) < 45 ) { - if ( (*p) > 39 ) { - if ( 42 <= (*p) && (*p) <= 43 ) - goto st199; - } else if ( (*p) >= 35 ) - goto st199; - } else if ( (*p) > 46 ) { - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; - } else if ( (*p) > 90 ) { - if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; - } else - goto st199; - } else - goto st199; - goto st0; -st257: - if ( ++p == pe ) - goto _test_eof257; -case 257: - switch( (*p) ) { - case 33: goto st199; - case 58: goto tr300; - case 124: goto st199; - case 126: goto st199; - } - if ( (*p) < 45 ) { - if ( (*p) > 39 ) { - if ( 42 <= (*p) && (*p) <= 43 ) - goto st199; - } else if ( (*p) >= 35 ) - goto st199; - } else if ( (*p) > 46 ) { - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto st199; - } else if ( (*p) > 90 ) { - if ( 94 <= (*p) && (*p) <= 122 ) - goto st199; - } else - goto st199; - } else - goto st199; + goto st197; goto st0; -tr300: +tr299: #line 238 "http_parser.rl" { parser->transfer_encoding = HTTP_CHUNKED; } #line 143 "http_parser.rl" @@ -5676,105 +5653,117 @@ tr300: parser->header_field_mark = NULL; parser->header_field_size = 0; } - goto st258; -st258: + goto st256; +st256: if ( ++p == pe ) - goto _test_eof258; -case 258: -#line 5685 "http_parser.c" + goto _test_eof256; +case 256: +#line 5662 "http_parser.c" switch( (*p) ) { - case 13: goto tr237; - case 32: goto st258; - case 105: goto tr302; + case 13: goto tr236; + case 32: goto st256; + case 105: goto tr301; } - goto tr236; -tr302: + goto tr235; +tr301: #line 118 "http_parser.rl" { parser->header_value_mark = p; parser->header_value_size = 0; } - goto st259; + goto st257; +st257: + if ( ++p == pe ) + goto _test_eof257; +case 257: +#line 5680 "http_parser.c" + switch( (*p) ) { + case 13: goto tr239; + case 100: goto st258; + } + goto st199; +st258: + if ( ++p == pe ) + goto _test_eof258; +case 258: + switch( (*p) ) { + case 13: goto tr239; + case 101: goto st259; + } + goto st199; st259: if ( ++p == pe ) goto _test_eof259; case 259: -#line 5703 "http_parser.c" switch( (*p) ) { - case 13: goto tr240; - case 100: goto st260; + case 13: goto tr239; + case 110: goto st260; } - goto st201; + goto st199; st260: if ( ++p == pe ) goto _test_eof260; case 260: switch( (*p) ) { - case 13: goto tr240; - case 101: goto st261; + case 13: goto tr239; + case 116: goto st261; } - goto st201; + goto st199; st261: if ( ++p == pe ) goto _test_eof261; case 261: switch( (*p) ) { - case 13: goto tr240; - case 110: goto st262; + case 13: goto tr239; + case 105: goto st262; } - goto st201; + goto st199; st262: if ( ++p == pe ) goto _test_eof262; case 262: switch( (*p) ) { - case 13: goto tr240; + case 13: goto tr239; case 116: goto st263; } - goto st201; + goto st199; st263: if ( ++p == pe ) goto _test_eof263; case 263: switch( (*p) ) { - case 13: goto tr240; - case 105: goto st264; + case 13: goto tr239; + case 121: goto st264; } - goto st201; + goto st199; st264: if ( ++p == pe ) goto _test_eof264; case 264: - switch( (*p) ) { - case 13: goto tr240; - case 116: goto st265; - } - goto st201; + if ( (*p) == 13 ) + goto tr309; + goto st199; st265: if ( ++p == pe ) goto _test_eof265; case 265: - switch( (*p) ) { - case 13: goto tr240; - case 121: goto st266; - } - goto st201; -st266: - if ( ++p == pe ) - goto _test_eof266; -case 266: if ( (*p) == 13 ) - goto tr310; - goto st201; + goto st194; + if ( (*p) > 9 ) { + if ( 11 <= (*p) ) + goto st265; + } else if ( (*p) >= 0 ) + goto st265; + goto st0; } _test_eof1: cs = 1; goto _test_eof; - _test_eof267: cs = 267; 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_eof268: cs = 268; 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; @@ -5788,7 +5777,7 @@ case 266: _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; - _test_eof269: cs = 269; 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_eof22: cs = 22; goto _test_eof; @@ -5951,7 +5940,7 @@ case 266: _test_eof179: cs = 179; goto _test_eof; _test_eof180: cs = 180; goto _test_eof; _test_eof181: cs = 181; goto _test_eof; - _test_eof270: cs = 270; 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; @@ -6036,12 +6025,11 @@ case 266: _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_eof: {} _out: {} } -#line 468 "http_parser.rl" +#line 469 "http_parser.rl" parser->cs = cs; diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index b1d8ce6092..9b699dc483 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -70,8 +70,25 @@ struct http_parser { enum http_parser_type type; size_t chunk_size; - unsigned eating:1; - unsigned error:1; + + /** + 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; diff --git a/deps/http_parser/http_parser.rl b/deps/http_parser/http_parser.rl index 18d0360f07..0d8fa50f15 100644 --- a/deps/http_parser/http_parser.rl +++ b/deps/http_parser/http_parser.rl @@ -378,8 +378,8 @@ do { \ Request_Line = ( Method " " Request_URI ("#" Fragment)? " " HTTP_Version CRLF ) ; StatusCode = (digit digit digit) $status_code; - ReasonPhrase = ascii+ -- ("\r" | "\n"); - StatusLine = HTTP_Version " " StatusCode " " ReasonPhrase CRLF; + ReasonPhrase = ascii* -- ("\r" | "\n"); + StatusLine = HTTP_Version " " StatusCode (" " ReasonPhrase)? CRLF; # chunked message trailing_headers = header*; @@ -427,6 +427,7 @@ http_parser_init (http_parser *parser, enum http_parser_type type) parser->on_path = NULL; parser->on_query_string = NULL; parser->on_uri = NULL; + parser->on_fragment = NULL; parser->on_header_field = NULL; parser->on_header_value = NULL; parser->on_headers_complete = NULL; diff --git a/deps/http_parser/test.c b/deps/http_parser/test.c index 6188629681..ba8329f12e 100644 --- a/deps/http_parser/test.c +++ b/deps/http_parser/test.c @@ -354,6 +354,16 @@ const struct message responses[] = ,.body= "" } +, {.name= "301 no response phrase" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301\r\n\r\n" + ,.should_keep_alive = TRUE + ,.status_code= 301 + ,.num_headers= 0 + ,.headers= {} + ,.body= "" +} + , {.name= NULL } /* sentinel */ };