ext/http11/http11_parser.c in mongrel-0.3.13.2 vs ext/http11/http11_parser.c in mongrel-0.3.13.3

- old
+ new

@@ -1,25 +1,10 @@ #line 1 "ext/http11/http11_parser.rl" -/* Mongrel Web Server - A Mostly Ruby HTTP server and Library - * - * Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/** + * Copyright (c) 2005 Zed A. Shaw + * You can redistribute it and/or modify it under the same terms as Ruby. */ - #include "http11_parser.h" #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <ctype.h> @@ -28,32 +13,32 @@ #define LEN(AT, FPC) (FPC - buffer - parser->AT) #define MARK(M,FPC) (parser->M = (FPC) - buffer) #define PTR_TO(F) (buffer + parser->F) /** machine **/ -#line 121 "ext/http11/http11_parser.rl" +#line 106 "ext/http11/http11_parser.rl" /** Data **/ -#line 39 "ext/http11/http11_parser.c" +#line 24 "ext/http11/http11_parser.c" static int http_parser_start = 0; static int http_parser_first_final = 51; static int http_parser_error = 1; -#line 125 "ext/http11/http11_parser.rl" +#line 110 "ext/http11/http11_parser.rl" int http_parser_init(http_parser *parser) { int cs = 0; -#line 51 "ext/http11/http11_parser.c" +#line 36 "ext/http11/http11_parser.c" { cs = http_parser_start; } -#line 129 "ext/http11/http11_parser.rl" +#line 114 "ext/http11/http11_parser.rl" parser->cs = cs; parser->body_start = 0; parser->content_len = 0; parser->mark = 0; parser->nread = 0; @@ -77,11 +62,11 @@ assert(*pe == '\0' && "pointer does not end on NUL"); assert(pe - p == len - off && "pointers aren't same distance"); -#line 83 "ext/http11/http11_parser.c" +#line 68 "ext/http11/http11_parser.c" { p -= 1; if ( ++p == pe ) goto _out; switch ( cs ) @@ -101,18 +86,18 @@ goto tr14; goto st1; st1: goto _out1; tr14: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st2; st2: if ( ++p == pe ) goto _out2; case 2: -#line 114 "ext/http11/http11_parser.c" +#line 99 "ext/http11/http11_parser.c" switch( (*p) ) { case 32: goto tr18; case 36: goto st32; case 95: goto st32; } @@ -124,21 +109,21 @@ goto st32; } else goto st32; goto st1; tr18: -#line 48 "ext/http11/http11_parser.rl" +#line 33 "ext/http11/http11_parser.rl" { if(parser->request_method != NULL) parser->request_method(parser->data, PTR_TO(mark), LEN(mark, p)); } goto st3; st3: if ( ++p == pe ) goto _out3; case 3: -#line 140 "ext/http11/http11_parser.c" +#line 125 "ext/http11/http11_parser.c" switch( (*p) ) { case 42: goto tr10; case 43: goto tr11; case 47: goto tr12; case 58: goto tr13; @@ -151,52 +136,52 @@ goto tr11; } else goto tr11; goto st1; tr10: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st4; st4: if ( ++p == pe ) goto _out4; case 4: -#line 164 "ext/http11/http11_parser.c" +#line 149 "ext/http11/http11_parser.c" if ( (*p) == 32 ) goto tr20; goto st1; tr20: -#line 52 "ext/http11/http11_parser.rl" +#line 37 "ext/http11/http11_parser.rl" { if(parser->request_uri != NULL) parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p)); } goto st5; tr32: -#line 56 "ext/http11/http11_parser.rl" +#line 41 "ext/http11/http11_parser.rl" { if(parser->query_string != NULL) parser->query_string(parser->data, PTR_TO(mark), LEN(mark, p)); } goto st5; st5: if ( ++p == pe ) goto _out5; case 5: -#line 186 "ext/http11/http11_parser.c" +#line 171 "ext/http11/http11_parser.c" if ( (*p) == 72 ) goto tr3; goto st1; tr3: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st6; st6: if ( ++p == pe ) goto _out6; case 6: -#line 198 "ext/http11/http11_parser.c" +#line 183 "ext/http11/http11_parser.c" if ( (*p) == 84 ) goto st7; goto st1; st7: if ( ++p == pe ) @@ -250,29 +235,29 @@ goto tr23; if ( 48 <= (*p) && (*p) <= 57 ) goto st13; goto st1; tr23: -#line 61 "ext/http11/http11_parser.rl" +#line 46 "ext/http11/http11_parser.rl" { if(parser->http_version != NULL) parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p)); } goto st14; tr35: -#line 43 "ext/http11/http11_parser.rl" +#line 28 "ext/http11/http11_parser.rl" { if(parser->http_field != NULL) { parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p)); } } goto st14; st14: if ( ++p == pe ) goto _out14; case 14: -#line 274 "ext/http11/http11_parser.c" +#line 259 "ext/http11/http11_parser.c" if ( (*p) == 10 ) goto st15; goto st1; st15: if ( ++p == pe ) @@ -308,11 +293,11 @@ case 16: if ( (*p) == 10 ) goto tr26; goto st1; tr26: -#line 66 "ext/http11/http11_parser.rl" +#line 51 "ext/http11/http11_parser.rl" { parser->body_start = p - buffer + 1; if(parser->header_done != NULL) parser->header_done(parser->data, p, 0); goto _out51; @@ -320,21 +305,21 @@ goto st51; st51: if ( ++p == pe ) goto _out51; case 51: -#line 326 "ext/http11/http11_parser.c" +#line 311 "ext/http11/http11_parser.c" goto st1; tr22: -#line 37 "ext/http11/http11_parser.rl" +#line 22 "ext/http11/http11_parser.rl" { MARK(field_start, p); } goto st17; st17: if ( ++p == pe ) goto _out17; case 17: -#line 336 "ext/http11/http11_parser.c" +#line 321 "ext/http11/http11_parser.c" switch( (*p) ) { case 33: goto st17; case 58: goto tr16; case 124: goto st17; case 126: goto st17; @@ -356,20 +341,20 @@ goto st17; } else goto st17; goto st1; tr16: -#line 38 "ext/http11/http11_parser.rl" +#line 23 "ext/http11/http11_parser.rl" { parser->field_len = LEN(field_start, p); } goto st18; st18: if ( ++p == pe ) goto _out18; case 18: -#line 371 "ext/http11/http11_parser.c" +#line 356 "ext/http11/http11_parser.c" if ( (*p) == 32 ) goto st19; goto st1; st19: if ( ++p == pe ) @@ -377,30 +362,30 @@ case 19: if ( (*p) == 13 ) goto tr35; goto tr38; tr38: -#line 42 "ext/http11/http11_parser.rl" +#line 27 "ext/http11/http11_parser.rl" { MARK(mark, p); } goto st20; st20: if ( ++p == pe ) goto _out20; case 20: -#line 390 "ext/http11/http11_parser.c" +#line 375 "ext/http11/http11_parser.c" if ( (*p) == 13 ) goto tr35; goto st20; tr11: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st21; st21: if ( ++p == pe ) goto _out21; case 21: -#line 402 "ext/http11/http11_parser.c" +#line 387 "ext/http11/http11_parser.c" switch( (*p) ) { case 43: goto st21; case 58: goto st22; } if ( (*p) < 48 ) { @@ -414,18 +399,18 @@ goto st21; } else goto st21; goto st1; tr13: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st22; st22: if ( ++p == pe ) goto _out22; case 22: -#line 427 "ext/http11/http11_parser.c" +#line 412 "ext/http11/http11_parser.c" switch( (*p) ) { case 32: goto tr20; case 37: goto st23; case 60: goto st1; case 62: goto st1; @@ -462,18 +447,18 @@ goto st22; } else goto st22; goto st1; tr12: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st25; st25: if ( ++p == pe ) goto _out25; case 25: -#line 475 "ext/http11/http11_parser.c" +#line 460 "ext/http11/http11_parser.c" switch( (*p) ) { case 32: goto tr20; case 37: goto st26; case 60: goto st1; case 62: goto st1; @@ -511,21 +496,21 @@ goto st25; } else goto st25; goto st1; tr30: -#line 52 "ext/http11/http11_parser.rl" +#line 37 "ext/http11/http11_parser.rl" { if(parser->request_uri != NULL) parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p)); } goto st28; st28: if ( ++p == pe ) goto _out28; case 28: -#line 527 "ext/http11/http11_parser.c" +#line 512 "ext/http11/http11_parser.c" switch( (*p) ) { case 32: goto tr32; case 37: goto tr37; case 60: goto st1; case 62: goto st1; @@ -536,18 +521,18 @@ goto st1; } else if ( (*p) >= 0 ) goto st1; goto tr36; tr36: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st29; st29: if ( ++p == pe ) goto _out29; case 29: -#line 549 "ext/http11/http11_parser.c" +#line 534 "ext/http11/http11_parser.c" switch( (*p) ) { case 32: goto tr32; case 37: goto st30; case 60: goto st1; case 62: goto st1; @@ -558,18 +543,18 @@ goto st1; } else if ( (*p) >= 0 ) goto st1; goto st29; tr37: -#line 35 "ext/http11/http11_parser.rl" +#line 20 "ext/http11/http11_parser.rl" {MARK(mark, p); } goto st30; st30: if ( ++p == pe ) goto _out30; case 30: -#line 571 "ext/http11/http11_parser.c" +#line 556 "ext/http11/http11_parser.c" if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st31; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) @@ -974,11 +959,11 @@ _out49: cs = 49; goto _out; _out50: cs = 50; goto _out; _out: {} } -#line 156 "ext/http11/http11_parser.rl" +#line 141 "ext/http11/http11_parser.rl" parser->cs = cs; parser->nread += p - (buffer + off); assert(p <= pe && "buffer overflow after parsing execute"); @@ -989,12 +974,12 @@ assert(parser->field_start < len && "field starts after buffer end"); if(parser->body_start) { /* final \r\n combo encountered so stop right here */ -#line 995 "ext/http11/http11_parser.c" -#line 170 "ext/http11/http11_parser.rl" +#line 980 "ext/http11/http11_parser.c" +#line 155 "ext/http11/http11_parser.rl" parser->nread++; } return(parser->nread); } @@ -1002,11 +987,11 @@ int http_parser_finish(http_parser *parser) { int cs = parser->cs; -#line 1008 "ext/http11/http11_parser.c" -#line 181 "ext/http11/http11_parser.rl" +#line 993 "ext/http11/http11_parser.c" +#line 166 "ext/http11/http11_parser.rl" parser->cs = cs; if (http_parser_has_error(parser) ) { return -1;