ext/http11_client/http11_parser.c in rev-0.2.1 vs ext/http11_client/http11_parser.c in rev-0.2.2
- old
+ new
@@ -22,22 +22,161 @@
/** Data **/
#line 27 "http11_parser.c"
-static const int httpclient_parser_start = 1;
-static const int httpclient_parser_first_final = 37;
-static const int httpclient_parser_error = 0;
+static const char _httpclient_parser_actions[] = {
+ 0, 1, 0, 1, 1, 1, 2, 1,
+ 3, 1, 4, 1, 5, 1, 7, 1,
+ 8, 1, 10, 2, 2, 3, 2, 6,
+ 0, 2, 6, 5, 2, 9, 10, 2,
+ 10, 9, 3, 2, 3, 4
+};
-static const int httpclient_parser_en_main = 1;
+static const short _httpclient_parser_key_offsets[] = {
+ 0, 10, 10, 11, 22, 26, 27, 28,
+ 39, 54, 75, 90, 110, 125, 146, 161,
+ 181, 196, 214, 229, 246, 247, 248, 249,
+ 250, 252, 255, 257, 260, 262, 264, 266,
+ 268, 269, 270, 286, 302, 304, 305, 306
+};
+static const char _httpclient_parser_trans_keys[] = {
+ 13, 48, 59, 72, 49, 57, 65, 70,
+ 97, 102, 10, 13, 32, 59, 9, 12,
+ 48, 57, 65, 70, 97, 102, 13, 32,
+ 9, 12, 10, 10, 13, 32, 59, 9,
+ 12, 48, 57, 65, 70, 97, 102, 33,
+ 124, 126, 35, 39, 42, 43, 45, 46,
+ 48, 57, 65, 90, 94, 122, 13, 32,
+ 33, 59, 61, 124, 126, 9, 12, 35,
+ 39, 42, 43, 45, 46, 48, 57, 65,
+ 90, 94, 122, 33, 124, 126, 35, 39,
+ 42, 43, 45, 46, 48, 57, 65, 90,
+ 94, 122, 13, 32, 33, 59, 124, 126,
+ 9, 12, 35, 39, 42, 43, 45, 46,
+ 48, 57, 65, 90, 94, 122, 33, 124,
+ 126, 35, 39, 42, 43, 45, 46, 48,
+ 57, 65, 90, 94, 122, 13, 32, 33,
+ 59, 61, 124, 126, 9, 12, 35, 39,
+ 42, 43, 45, 46, 48, 57, 65, 90,
+ 94, 122, 33, 124, 126, 35, 39, 42,
+ 43, 45, 46, 48, 57, 65, 90, 94,
+ 122, 13, 32, 33, 59, 124, 126, 9,
+ 12, 35, 39, 42, 43, 45, 46, 48,
+ 57, 65, 90, 94, 122, 33, 124, 126,
+ 35, 39, 42, 43, 45, 46, 48, 57,
+ 65, 90, 94, 122, 13, 33, 59, 61,
+ 124, 126, 35, 39, 42, 43, 45, 46,
+ 48, 57, 65, 90, 94, 122, 33, 124,
+ 126, 35, 39, 42, 43, 45, 46, 48,
+ 57, 65, 90, 94, 122, 13, 33, 59,
+ 124, 126, 35, 39, 42, 43, 45, 46,
+ 48, 57, 65, 90, 94, 122, 84, 84,
+ 80, 47, 48, 57, 46, 48, 57, 48,
+ 57, 32, 48, 57, 48, 57, 48, 57,
+ 48, 57, 13, 32, 13, 10, 13, 33,
+ 124, 126, 35, 39, 42, 43, 45, 46,
+ 48, 57, 65, 90, 94, 122, 33, 58,
+ 124, 126, 35, 39, 42, 43, 45, 46,
+ 48, 57, 65, 90, 94, 122, 13, 32,
+ 13, 13, 0
+};
+
+static const char _httpclient_parser_single_lengths[] = {
+ 4, 0, 1, 3, 2, 1, 1, 3,
+ 3, 7, 3, 6, 3, 7, 3, 6,
+ 3, 6, 3, 5, 1, 1, 1, 1,
+ 0, 1, 0, 1, 0, 0, 0, 2,
+ 1, 1, 4, 4, 2, 1, 1, 0
+};
+
+static const char _httpclient_parser_range_lengths[] = {
+ 3, 0, 0, 4, 1, 0, 0, 4,
+ 6, 7, 6, 7, 6, 7, 6, 7,
+ 6, 6, 6, 6, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 0, 6, 6, 0, 0, 0, 0
+};
+
+static const unsigned char _httpclient_parser_index_offsets[] = {
+ 0, 8, 8, 10, 18, 22, 24, 26,
+ 34, 44, 59, 69, 83, 93, 108, 118,
+ 132, 142, 155, 165, 177, 179, 181, 183,
+ 185, 187, 190, 192, 195, 197, 199, 201,
+ 204, 206, 208, 219, 230, 233, 235, 237
+};
+
+static const char _httpclient_parser_indicies[] = {
+ 14, 15, 17, 18, 16, 16, 16, 0,
+ 30, 0, 63, 37, 64, 37, 39, 39,
+ 39, 0, 19, 32, 32, 0, 29, 0,
+ 31, 0, 38, 37, 40, 37, 39, 39,
+ 39, 0, 58, 58, 58, 58, 58, 58,
+ 58, 58, 58, 0, 42, 41, 43, 44,
+ 45, 43, 43, 41, 43, 43, 43, 43,
+ 43, 43, 0, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 0, 34, 33, 35,
+ 36, 35, 35, 33, 35, 35, 35, 35,
+ 35, 35, 0, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 0, 65, 41, 66,
+ 67, 68, 66, 66, 41, 66, 66, 66,
+ 66, 66, 66, 0, 69, 69, 69, 69,
+ 69, 69, 69, 69, 69, 0, 60, 33,
+ 61, 62, 61, 61, 33, 61, 61, 61,
+ 61, 61, 61, 0, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 0, 24, 25,
+ 26, 27, 25, 25, 25, 25, 25, 25,
+ 25, 25, 0, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 0, 21, 22, 23,
+ 22, 22, 22, 22, 22, 22, 22, 22,
+ 0, 1, 0, 56, 0, 2, 0, 5,
+ 0, 7, 0, 6, 7, 0, 13, 0,
+ 12, 13, 0, 4, 0, 3, 0, 57,
+ 0, 54, 55, 53, 49, 48, 28, 0,
+ 19, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 0, 8, 9, 8, 8, 8,
+ 8, 8, 8, 8, 8, 0, 47, 52,
+ 51, 47, 46, 49, 50, 0, 0
+};
+
+static const char _httpclient_parser_trans_targs_wi[] = {
+ 1, 21, 23, 30, 29, 24, 26, 25,
+ 35, 36, 17, 19, 28, 27, 2, 3,
+ 7, 16, 20, 5, 35, 2, 19, 16,
+ 2, 17, 16, 18, 34, 39, 39, 39,
+ 4, 4, 5, 11, 8, 4, 5, 7,
+ 8, 4, 5, 9, 8, 10, 37, 33,
+ 32, 33, 32, 37, 36, 32, 33, 38,
+ 22, 31, 9, 11, 6, 15, 12, 6,
+ 12, 6, 13, 12, 14, 15, 13
+};
+
+static const char _httpclient_parser_trans_actions_wi[] = {
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 5, 3, 7, 13, 0, 0, 1,
+ 1, 0, 1, 0, 3, 9, 0, 9,
+ 34, 0, 34, 19, 0, 17, 28, 31,
+ 0, 9, 9, 0, 9, 15, 15, 0,
+ 15, 34, 34, 0, 34, 19, 0, 9,
+ 0, 11, 1, 7, 7, 22, 25, 22,
+ 0, 0, 3, 7, 9, 0, 9, 15,
+ 15, 34, 0, 34, 19, 7, 3
+};
+
+static const int httpclient_parser_start = 0;
+
+static const int httpclient_parser_first_final = 39;
+
+static const int httpclient_parser_error = 1;
+
#line 99 "http11_parser.rl"
int httpclient_parser_init(httpclient_parser *parser) {
int cs = 0;
-#line 39 "http11_parser.c"
+#line 178 "http11_parser.c"
{
cs = httpclient_parser_start;
}
#line 103 "http11_parser.rl"
parser->cs = cs;
@@ -65,1003 +204,154 @@
assert(*pe == '\0' && "pointer does not end on NUL");
assert(pe - p == len - off && "pointers aren't same distance");
-#line 71 "http11_parser.c"
+#line 210 "http11_parser.c"
{
+ int _klen;
+ unsigned int _trans;
+ const char *_acts;
+ unsigned int _nacts;
+ const char *_keys;
+
if ( p == pe )
goto _out;
- switch ( cs )
- {
-case 1:
- switch( (*p) ) {
- case 13: goto st2;
- case 48: goto tr2;
- case 59: goto st16;
- case 72: goto tr5;
+_resume:
+ if ( cs == 1 )
+ goto _out;
+ _keys = _httpclient_parser_trans_keys + _httpclient_parser_key_offsets[cs];
+ _trans = _httpclient_parser_index_offsets[cs];
+
+ _klen = _httpclient_parser_single_lengths[cs];
+ if ( _klen > 0 ) {
+ const char *_lower = _keys;
+ const char *_mid;
+ const char *_upper = _keys + _klen - 1;
+ while (1) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + ((_upper-_lower) >> 1);
+ if ( (*p) < *_mid )
+ _upper = _mid - 1;
+ else if ( (*p) > *_mid )
+ _lower = _mid + 1;
+ else {
+ _trans += (_mid - _keys);
+ goto _match;
+ }
+ }
+ _keys += _klen;
+ _trans += _klen;
}
- if ( (*p) < 65 ) {
- if ( 49 <= (*p) && (*p) <= 57 )
- goto tr3;
- } else if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto tr3;
- } else
- goto tr3;
- goto st0;
-st0:
- goto _out0;
-tr38:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st2;
-tr43:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st2;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
-#line 117 "http11_parser.c"
- if ( (*p) == 10 )
- goto tr6;
- goto st0;
-tr6:
-#line 53 "http11_parser.rl"
- {
- parser->last_chunk(parser->data, NULL, 0);
- }
-#line 57 "http11_parser.rl"
- {
- parser->body_start = p - buffer + 1;
- if(parser->header_done != NULL)
- parser->header_done(parser->data, p + 1, pe - p - 1);
- goto _out37;
- }
- goto st37;
-tr13:
-#line 57 "http11_parser.rl"
- {
- parser->body_start = p - buffer + 1;
- if(parser->header_done != NULL)
- parser->header_done(parser->data, p + 1, pe - p - 1);
- goto _out37;
- }
- goto st37;
-tr14:
-#line 57 "http11_parser.rl"
- {
- parser->body_start = p - buffer + 1;
- if(parser->header_done != NULL)
- parser->header_done(parser->data, p + 1, pe - p - 1);
- goto _out37;
- }
-#line 53 "http11_parser.rl"
- {
- parser->last_chunk(parser->data, NULL, 0);
- }
- goto st37;
-st37:
- if ( ++p == pe )
- goto _out37;
-case 37:
-#line 160 "http11_parser.c"
- goto st0;
-tr2:
-#line 23 "http11_parser.rl"
- {MARK(mark, p); }
- goto st3;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
-#line 170 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr8;
- case 32: goto tr7;
- case 59: goto tr10;
+
+ _klen = _httpclient_parser_range_lengths[cs];
+ if ( _klen > 0 ) {
+ const char *_lower = _keys;
+ const char *_mid;
+ const char *_upper = _keys + (_klen<<1) - 2;
+ while (1) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
+ if ( (*p) < _mid[0] )
+ _upper = _mid - 2;
+ else if ( (*p) > _mid[1] )
+ _lower = _mid + 2;
+ else {
+ _trans += ((_mid - _keys)>>1);
+ goto _match;
+ }
+ }
+ _trans += _klen;
}
- if ( (*p) < 48 ) {
- if ( 9 <= (*p) && (*p) <= 12 )
- goto tr7;
- } else if ( (*p) > 57 ) {
- if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto st7;
- } else if ( (*p) >= 65 )
- goto st7;
- } else
- goto st7;
- goto st0;
-tr7:
-#line 49 "http11_parser.rl"
+
+_match:
+ _trans = _httpclient_parser_indicies[_trans];
+ cs = _httpclient_parser_trans_targs_wi[_trans];
+
+ if ( _httpclient_parser_trans_actions_wi[_trans] == 0 )
+ goto _again;
+
+ _acts = _httpclient_parser_actions + _httpclient_parser_trans_actions_wi[_trans];
+ _nacts = (unsigned int) *_acts++;
+ while ( _nacts-- > 0 )
{
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
- }
- goto st4;
-tr18:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st4;
-tr24:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st4;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
-#line 216 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto st5;
- case 32: goto st4;
- }
- if ( 9 <= (*p) && (*p) <= 12 )
- goto st4;
- goto st0;
-tr15:
-#line 49 "http11_parser.rl"
- {
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
- }
- goto st5;
-tr19:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st5;
-tr25:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st5;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
-#line 252 "http11_parser.c"
- if ( (*p) == 10 )
- goto tr13;
- goto st0;
-tr8:
-#line 49 "http11_parser.rl"
- {
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
- }
- goto st6;
-tr29:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st6;
-tr34:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st6;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
-#line 284 "http11_parser.c"
- if ( (*p) == 10 )
- goto tr14;
- goto st0;
-tr3:
+ switch ( *_acts++ )
+ {
+ case 0:
#line 23 "http11_parser.rl"
{MARK(mark, p); }
- goto st7;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
-#line 296 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr15;
- case 32: goto tr7;
- case 59: goto tr16;
- }
- if ( (*p) < 48 ) {
- if ( 9 <= (*p) && (*p) <= 12 )
- goto tr7;
- } else if ( (*p) > 57 ) {
- if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto st7;
- } else if ( (*p) >= 65 )
- goto st7;
- } else
- goto st7;
- goto st0;
-tr16:
-#line 49 "http11_parser.rl"
- {
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
- }
- goto st8;
-tr21:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st8;
-tr27:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st8;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
-#line 342 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto tr17;
- case 124: goto tr17;
- case 126: goto tr17;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr17;
- } else if ( (*p) >= 35 )
- goto tr17;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr17;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr17;
- } else
- goto tr17;
- } else
- goto tr17;
- goto st0;
-tr17:
+ break;
+ case 1:
#line 25 "http11_parser.rl"
{ MARK(field_start, p); }
- goto st9;
-st9:
- if ( ++p == pe )
- goto _out9;
-case 9:
-#line 374 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr19;
- case 32: goto tr18;
- case 33: goto st9;
- case 59: goto tr21;
- case 61: goto tr22;
- case 124: goto st9;
- case 126: goto st9;
- }
- if ( (*p) < 45 ) {
- if ( (*p) < 35 ) {
- if ( 9 <= (*p) && (*p) <= 12 )
- goto tr18;
- } else if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st9;
- } else
- goto st9;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st9;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st9;
- } else
- goto st9;
- } else
- goto st9;
- goto st0;
-tr22:
+ break;
+ case 2:
#line 27 "http11_parser.rl"
{
parser->field_len = LEN(field_start, p);
}
+ break;
+ case 3:
#line 31 "http11_parser.rl"
{ MARK(mark, p); }
- goto st10;
-st10:
- if ( ++p == pe )
- goto _out10;
-case 10:
-#line 417 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto tr23;
- case 124: goto tr23;
- case 126: goto tr23;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr23;
- } else if ( (*p) >= 35 )
- goto tr23;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr23;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr23;
- } else
- goto tr23;
- } else
- goto tr23;
- goto st0;
-tr23:
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st11;
-st11:
- if ( ++p == pe )
- goto _out11;
-case 11:
-#line 449 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr25;
- case 32: goto tr24;
- case 33: goto st11;
- case 59: goto tr27;
- case 124: goto st11;
- case 126: goto st11;
- }
- if ( (*p) < 45 ) {
- if ( (*p) < 35 ) {
- if ( 9 <= (*p) && (*p) <= 12 )
- goto tr24;
- } else if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st11;
- } else
- goto st11;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st11;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st11;
- } else
- goto st11;
- } else
- goto st11;
- goto st0;
-tr10:
-#line 49 "http11_parser.rl"
- {
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
- }
- goto st12;
-tr31:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
+ break;
+ case 4:
#line 33 "http11_parser.rl"
{
parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
}
- goto st12;
-tr36:
-#line 33 "http11_parser.rl"
+ break;
+ case 5:
+#line 37 "http11_parser.rl"
{
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
+ parser->reason_phrase(parser->data, PTR_TO(mark), LEN(mark, p));
}
- goto st12;
-st12:
- if ( ++p == pe )
- goto _out12;
-case 12:
-#line 507 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto tr28;
- case 124: goto tr28;
- case 126: goto tr28;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr28;
- } else if ( (*p) >= 35 )
- goto tr28;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr28;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr28;
- } else
- goto tr28;
- } else
- goto tr28;
- goto st0;
-tr28:
-#line 25 "http11_parser.rl"
- { MARK(field_start, p); }
- goto st13;
-st13:
- if ( ++p == pe )
- goto _out13;
-case 13:
-#line 539 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr29;
- case 32: goto tr18;
- case 33: goto st13;
- case 59: goto tr31;
- case 61: goto tr32;
- case 124: goto st13;
- case 126: goto st13;
- }
- if ( (*p) < 45 ) {
- if ( (*p) < 35 ) {
- if ( 9 <= (*p) && (*p) <= 12 )
- goto tr18;
- } else if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st13;
- } else
- goto st13;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st13;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st13;
- } else
- goto st13;
- } else
- goto st13;
- goto st0;
-tr32:
-#line 27 "http11_parser.rl"
+ break;
+ case 6:
+#line 41 "http11_parser.rl"
{
- parser->field_len = LEN(field_start, p);
+ parser->status_code(parser->data, PTR_TO(mark), LEN(mark, p));
}
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st14;
-st14:
- if ( ++p == pe )
- goto _out14;
-case 14:
-#line 582 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto tr33;
- case 124: goto tr33;
- case 126: goto tr33;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr33;
- } else if ( (*p) >= 35 )
- goto tr33;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr33;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr33;
- } else
- goto tr33;
- } else
- goto tr33;
- goto st0;
-tr33:
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st15;
-st15:
- if ( ++p == pe )
- goto _out15;
-case 15:
-#line 614 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr34;
- case 32: goto tr24;
- case 33: goto st15;
- case 59: goto tr36;
- case 124: goto st15;
- case 126: goto st15;
- }
- if ( (*p) < 45 ) {
- if ( (*p) < 35 ) {
- if ( 9 <= (*p) && (*p) <= 12 )
- goto tr24;
- } else if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st15;
- } else
- goto st15;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st15;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st15;
- } else
- goto st15;
- } else
- goto st15;
- goto st0;
-tr40:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st16;
-tr45:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
- }
- goto st16;
-st16:
- if ( ++p == pe )
- goto _out16;
-case 16:
-#line 666 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto tr37;
- case 124: goto tr37;
- case 126: goto tr37;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr37;
- } else if ( (*p) >= 35 )
- goto tr37;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr37;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr37;
- } else
- goto tr37;
- } else
- goto tr37;
- goto st0;
-tr37:
-#line 25 "http11_parser.rl"
- { MARK(field_start, p); }
- goto st17;
-st17:
- if ( ++p == pe )
- goto _out17;
-case 17:
-#line 698 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr38;
- case 33: goto st17;
- case 59: goto tr40;
- case 61: goto tr41;
- case 124: goto st17;
- case 126: goto st17;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st17;
- } else if ( (*p) >= 35 )
- goto st17;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st17;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st17;
- } else
- goto st17;
- } else
- goto st17;
- goto st0;
-tr41:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st18;
-st18:
- if ( ++p == pe )
- goto _out18;
-case 18:
-#line 737 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto tr42;
- case 124: goto tr42;
- case 126: goto tr42;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr42;
- } else if ( (*p) >= 35 )
- goto tr42;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr42;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr42;
- } else
- goto tr42;
- } else
- goto tr42;
- goto st0;
-tr42:
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st19;
-st19:
- if ( ++p == pe )
- goto _out19;
-case 19:
-#line 769 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr43;
- case 33: goto st19;
- case 59: goto tr45;
- case 124: goto st19;
- case 126: goto st19;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st19;
- } else if ( (*p) >= 35 )
- goto st19;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st19;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st19;
- } else
- goto st19;
- } else
- goto st19;
- goto st0;
-tr5:
-#line 23 "http11_parser.rl"
- {MARK(mark, p); }
- goto st20;
-st20:
- if ( ++p == pe )
- goto _out20;
-case 20:
-#line 803 "http11_parser.c"
- if ( (*p) == 84 )
- goto st21;
- goto st0;
-st21:
- if ( ++p == pe )
- goto _out21;
-case 21:
- if ( (*p) == 84 )
- goto st22;
- goto st0;
-st22:
- if ( ++p == pe )
- goto _out22;
-case 22:
- if ( (*p) == 80 )
- goto st23;
- goto st0;
-st23:
- if ( ++p == pe )
- goto _out23;
-case 23:
- if ( (*p) == 47 )
- goto st24;
- goto st0;
-st24:
- if ( ++p == pe )
- goto _out24;
-case 24:
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st25;
- goto st0;
-st25:
- if ( ++p == pe )
- goto _out25;
-case 25:
- if ( (*p) == 46 )
- goto st26;
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st25;
- goto st0;
-st26:
- if ( ++p == pe )
- goto _out26;
-case 26:
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st27;
- goto st0;
-st27:
- if ( ++p == pe )
- goto _out27;
-case 27:
- if ( (*p) == 32 )
- goto tr53;
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st27;
- goto st0;
-tr53:
+ break;
+ case 7:
#line 45 "http11_parser.rl"
{
parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p));
}
- goto st28;
-st28:
- if ( ++p == pe )
- goto _out28;
-case 28:
-#line 870 "http11_parser.c"
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr54;
- goto st0;
-tr54:
-#line 23 "http11_parser.rl"
- {MARK(mark, p); }
- goto st29;
-st29:
- if ( ++p == pe )
- goto _out29;
-case 29:
-#line 882 "http11_parser.c"
- if ( (*p) == 32 )
- goto tr55;
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st29;
- goto st0;
-tr55:
-#line 41 "http11_parser.rl"
- {
- parser->status_code(parser->data, PTR_TO(mark), LEN(mark, p));
+ break;
+ case 8:
+#line 49 "http11_parser.rl"
+ {
+ parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
}
- goto st30;
-st30:
- if ( ++p == pe )
- goto _out30;
-case 30:
-#line 898 "http11_parser.c"
- goto tr57;
-tr57:
-#line 23 "http11_parser.rl"
- {MARK(mark, p); }
- goto st31;
-st31:
- if ( ++p == pe )
- goto _out31;
-case 31:
-#line 908 "http11_parser.c"
- if ( (*p) == 13 )
- goto tr59;
- goto st31;
-tr65:
-#line 33 "http11_parser.rl"
- {
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
+ break;
+ case 9:
+#line 53 "http11_parser.rl"
+ {
+ parser->last_chunk(parser->data, NULL, 0);
}
- goto st32;
-tr59:
-#line 37 "http11_parser.rl"
+ break;
+ case 10:
+#line 57 "http11_parser.rl"
{
- parser->reason_phrase(parser->data, PTR_TO(mark), LEN(mark, p));
+ parser->body_start = p - buffer + 1;
+ if(parser->header_done != NULL)
+ parser->header_done(parser->data, p + 1, pe - p - 1);
+ goto _out;
}
- goto st32;
-st32:
- if ( ++p == pe )
- goto _out32;
-case 32:
-#line 928 "http11_parser.c"
- if ( (*p) == 10 )
- goto st33;
- goto st0;
-st33:
- if ( ++p == pe )
- goto _out33;
-case 33:
- switch( (*p) ) {
- case 13: goto st5;
- case 33: goto tr61;
- case 124: goto tr61;
- case 126: goto tr61;
+ break;
+#line 347 "http11_parser.c"
+ }
}
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto tr61;
- } else if ( (*p) >= 35 )
- goto tr61;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr61;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto tr61;
- } else
- goto tr61;
- } else
- goto tr61;
- goto st0;
-tr61:
-#line 25 "http11_parser.rl"
- { MARK(field_start, p); }
- goto st34;
-st34:
- if ( ++p == pe )
- goto _out34;
-case 34:
-#line 968 "http11_parser.c"
- switch( (*p) ) {
- case 33: goto st34;
- case 58: goto tr63;
- case 124: goto st34;
- case 126: goto st34;
- }
- if ( (*p) < 45 ) {
- if ( (*p) > 39 ) {
- if ( 42 <= (*p) && (*p) <= 43 )
- goto st34;
- } else if ( (*p) >= 35 )
- goto st34;
- } else if ( (*p) > 46 ) {
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st34;
- } else if ( (*p) > 90 ) {
- if ( 94 <= (*p) && (*p) <= 122 )
- goto st34;
- } else
- goto st34;
- } else
- goto st34;
- goto st0;
-tr66:
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st35;
-tr63:
-#line 27 "http11_parser.rl"
- {
- parser->field_len = LEN(field_start, p);
- }
- goto st35;
-st35:
- if ( ++p == pe )
- goto _out35;
-case 35:
-#line 1007 "http11_parser.c"
- switch( (*p) ) {
- case 13: goto tr65;
- case 32: goto tr66;
- }
- goto tr64;
-tr64:
-#line 31 "http11_parser.rl"
- { MARK(mark, p); }
- goto st36;
-st36:
- if ( ++p == pe )
- goto _out36;
-case 36:
-#line 1021 "http11_parser.c"
- if ( (*p) == 13 )
- goto tr65;
- goto st36;
- }
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out37: cs = 37; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
- _out8: cs = 8; goto _out;
- _out9: cs = 9; goto _out;
- _out10: cs = 10; goto _out;
- _out11: cs = 11; goto _out;
- _out12: cs = 12; goto _out;
- _out13: cs = 13; goto _out;
- _out14: cs = 14; goto _out;
- _out15: cs = 15; goto _out;
- _out16: cs = 16; goto _out;
- _out17: cs = 17; goto _out;
- _out18: cs = 18; goto _out;
- _out19: cs = 19; goto _out;
- _out20: cs = 20; goto _out;
- _out21: cs = 21; goto _out;
- _out22: cs = 22; goto _out;
- _out23: cs = 23; goto _out;
- _out24: cs = 24; goto _out;
- _out25: cs = 25; goto _out;
- _out26: cs = 26; goto _out;
- _out27: cs = 27; goto _out;
- _out28: cs = 28; goto _out;
- _out29: cs = 29; goto _out;
- _out30: cs = 30; goto _out;
- _out31: cs = 31; goto _out;
- _out32: cs = 32; goto _out;
- _out33: cs = 33; goto _out;
- _out34: cs = 34; goto _out;
- _out35: cs = 35; goto _out;
- _out36: cs = 36; goto _out;
+_again:
+ if ( ++p != pe )
+ goto _resume;
_out: {}
}
#line 130 "http11_parser.rl"
parser->cs = cs;
@@ -1075,11 +365,11 @@
assert(parser->field_start < len && "field starts after buffer end");
if(parser->body_start) {
/* final \r\n combo encountered so stop right here */
-#line 1081 "http11_parser.c"
+#line 371 "http11_parser.c"
#line 144 "http11_parser.rl"
parser->nread++;
}
return(parser->nread);
@@ -1088,10 +378,10 @@
int httpclient_parser_finish(httpclient_parser *parser)
{
int cs = parser->cs;
-#line 1094 "http11_parser.c"
+#line 384 "http11_parser.c"
#line 155 "http11_parser.rl"
parser->cs = cs;
if (httpclient_parser_has_error(parser) ) {