mongrel 1.1.5 → 1.2.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,68 @@
1
+ === 1.2.0.pre2 / 2010-03-18
2
+
3
+ Improvements:
4
+
5
+ * Ruby 1.9 early compatbility: Merged commits form Eric Wong and Matt Aimonetti.
6
+ * Better RubyGems support thanks to added env she-bang to mongrel_rails executable.
7
+ * Smartly load http11 extension using fat-binary approach.
8
+
9
+ Bugfixes:
10
+
11
+ * Fixed proper version reporting under 1.9
12
+ * Consider MinGW as valid Windows platform.
13
+ * Properly drop PID when daemonizing (EngineYard patched 1.1.5.1).
14
+
15
+ Reorganization:
16
+
17
+ * Rake task project reorganization and reformat using Hoe.
18
+ * Compile extension using rake-compiler
19
+ * Upgraded http11_parser to work with Ragel 6.2
20
+ * Deprecated obsolete Windows service example scripts (from 2006!)
21
+ * Relocate Http11 JRuby extension to share http11 C extension folder and name.
22
+
23
+ === 1.1.5 / 2008-05-22
24
+
25
+ * Fix bug where num_processors is not actually set from mongrel_rails.
26
+
27
+
28
+ === 1.1.4 / 2008-02-29
29
+
30
+ * Fix camping handler. Correct treatment of @throttle parameter.
31
+
32
+
33
+ === 1.1.3 / 2007-12-29
34
+
35
+ * Fix security flaw of DirHandler; reported on mailing list.
36
+
37
+
38
+ === 1.1.2 / 2007-12-15
39
+
40
+ * Fix worker termination bug; fix JRuby 1.0.3 load order issue; fix require issue on systems without Rubygems.
41
+
42
+
43
+ === 1.1.1 / 2007-11-12
44
+
45
+ * Fix mongrel_rails restart bug; fix bug with Rack status codes.
46
+
47
+
48
+ === 1.1 / 2007-11-01
49
+
50
+ * Pure Ruby URIClassifier.
51
+ * More modular architecture.
52
+ * JRuby support.
53
+ * Move C URIClassifier into mongrel_experimental project.
54
+
55
+
56
+ === 1.0.4 / 2007-10-29
57
+
58
+ * Backport fixes for versioning inconsistency, mongrel_rails bug, and DirHandler bug.
59
+
60
+
61
+ === 1.0.3
62
+
63
+ * Fix user-switching bug; make people upgrade to the latest from the RC.
64
+
65
+
66
+ === 1.0.2
67
+
68
+ * Signed gem; many minor bugfixes and patches.
@@ -1,15 +1,18 @@
1
- bin/mongrel_rails
2
- CHANGELOG
3
1
  COPYING
2
+ History.txt
3
+ LICENSE
4
+ Manifest.txt
5
+ README.txt
6
+ Rakefile
7
+ TODO
8
+ bin/mongrel_rails
4
9
  examples/builder.rb
5
- examples/camping/blog.rb
6
10
  examples/camping/README
11
+ examples/camping/blog.rb
7
12
  examples/camping/tepee.rb
8
13
  examples/httpd.conf
9
14
  examples/mime.yaml
10
15
  examples/mongrel.conf
11
- examples/mongrel_simple_ctrl.rb
12
- examples/mongrel_simple_service.rb
13
16
  examples/monitrc
14
17
  examples/random_thrash.rb
15
18
  examples/simpletest.rb
@@ -22,9 +25,10 @@ ext/http11/http11_parser.h
22
25
  ext/http11/http11_parser.java.rl
23
26
  ext/http11/http11_parser.rl
24
27
  ext/http11/http11_parser_common.rl
25
- ext/http11_java/Http11Service.java
26
- ext/http11_java/org/jruby/mongrel/Http11.java
27
- ext/http11_java/org/jruby/mongrel/Http11Parser.java
28
+ ext/http11/Http11Service.java
29
+ ext/http11/org/jruby/mongrel/Http11.java
30
+ ext/http11/org/jruby/mongrel/Http11Parser.java
31
+ lib/mongrel.rb
28
32
  lib/mongrel/camping.rb
29
33
  lib/mongrel/cgi.rb
30
34
  lib/mongrel/command.rb
@@ -42,13 +46,10 @@ lib/mongrel/rails.rb
42
46
  lib/mongrel/stats.rb
43
47
  lib/mongrel/tcphack.rb
44
48
  lib/mongrel/uri_classifier.rb
45
- lib/mongrel.rb
46
- LICENSE
47
- Manifest
48
- mongrel-public_cert.pem
49
- mongrel.gemspec
50
- README
51
49
  setup.rb
50
+ tasks/gem.rake
51
+ tasks/native.rake
52
+ tasks/ragel.rake
52
53
  test/mime.yaml
53
54
  test/mongrel.conf
54
55
  test/test_cgi_wrapper.rb
@@ -65,5 +66,4 @@ test/test_stats.rb
65
66
  test/test_uriclassifier.rb
66
67
  test/test_ws.rb
67
68
  test/testhelp.rb
68
- TODO
69
69
  tools/trickletest.rb
@@ -1,5 +1,11 @@
1
1
  = Mongrel: Simple Fast Mostly Ruby Web Server
2
2
 
3
+ * http://mongrel.rubyforge.org/
4
+ * http://rubyforge.org/projects/mongrel
5
+ * http://github.com/luislavena/mongrel
6
+
7
+ == Description
8
+
3
9
  Mongrel is a small library that provides a very fast HTTP 1.1 server for Ruby web applications. It is not particular to any framework, and is intended to be just enough to get a web application running behind a more complete and robust web server.
4
10
 
5
11
  What makes Mongrel so fast is the careful use of an Ragel extension to provide fast, accurate HTTP 1.1 protocol parsing. This makes the server scream without too many portability issues.
@@ -0,0 +1,8 @@
1
+ #
2
+ # NOTE: Keep this file clean.
3
+ # Add your customizations inside tasks directory.
4
+ # Thank You.
5
+ #
6
+
7
+ # load rakefile extensions (tasks)
8
+ Dir['tasks/*.rake'].sort.each { |f| load f }
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ #
1
3
  # Copyright (c) 2005 Zed A. Shaw
2
4
  # You can redistribute it and/or modify it under the same terms as Ruby.
3
5
  #
@@ -90,6 +92,7 @@ module Mongrel
90
92
  end
91
93
 
92
94
  daemonize
95
+ write_pid_file
93
96
  log "Daemonized, any open files are closed. Look at #{defaults[:pid_file]} and #{defaults[:log_file]} for info."
94
97
  log "Settings loaded from #{@config_file} (they override command line)." if @config_file
95
98
  end
@@ -128,9 +131,7 @@ module Mongrel
128
131
  config.run
129
132
  config.log "Mongrel #{Mongrel::Const::MONGREL_VERSION} available at #{@address}:#{@port}"
130
133
 
131
- if config.defaults[:daemon]
132
- config.write_pid_file
133
- else
134
+ unless config.defaults[:daemon]
134
135
  config.log "Use CTRL-C to stop."
135
136
  end
136
137
 
@@ -194,7 +195,7 @@ module Mongrel
194
195
  end
195
196
 
196
197
  def Mongrel::send_signal(signal, pid_file)
197
- pid = open(pid_file).read.to_i
198
+ pid = File.read(pid_file).to_i
198
199
  print "Sending #{signal} to Mongrel at PID #{pid}..."
199
200
  begin
200
201
  Process.kill(signal, pid)
File without changes
@@ -4,6 +4,7 @@
4
4
  #define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "NULL found for " # T " when shouldn't be.");
5
5
  #define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name);
6
6
  #define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "Wrong argument type for " # V " required " # T);
7
+ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
7
8
 
8
9
  #ifdef DEBUG
9
10
  #define TRACE() fprintf(stderr, "> %s:%d:%s\n", __FILE__, __LINE__, __FUNCTION__)
@@ -7,7 +7,20 @@
7
7
  #include <assert.h>
8
8
  #include <string.h>
9
9
  #include "http11_parser.h"
10
- #include <ctype.h>
10
+
11
+ #ifndef RSTRING_PTR
12
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
13
+ #endif
14
+ #ifndef RSTRING_LEN
15
+ #define RSTRING_LEN(s) (RSTRING(s)->len)
16
+ #endif
17
+
18
+ #ifndef RSTRING_PTR
19
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
20
+ #endif
21
+ #ifndef RSTRING_LEN
22
+ #define RSTRING_LEN(s) (RSTRING(s)->len)
23
+ #endif
11
24
 
12
25
  static VALUE mMongrel;
13
26
  static VALUE cHttpParser;
@@ -15,8 +28,9 @@ static VALUE eHttpParserError;
15
28
 
16
29
  #define id_handler_map rb_intern("@handler_map")
17
30
  #define id_http_body rb_intern("@http_body")
31
+ #define HTTP_PREFIX "HTTP_"
32
+ #define HTTP_PREFIX_LEN (sizeof(HTTP_PREFIX) - 1)
18
33
 
19
- static VALUE global_http_prefix;
20
34
  static VALUE global_request_method;
21
35
  static VALUE global_request_uri;
22
36
  static VALUE global_fragment;
@@ -59,10 +73,119 @@ DEF_MAX_LENGTH(REQUEST_PATH, 1024);
59
73
  DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
60
74
  DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32)));
61
75
 
76
+ struct common_field {
77
+ const signed long len;
78
+ const char *name;
79
+ VALUE value;
80
+ };
81
+
82
+ /*
83
+ * A list of common HTTP headers we expect to receive.
84
+ * This allows us to avoid repeatedly creating identical string
85
+ * objects to be used with rb_hash_aset().
86
+ */
87
+ static struct common_field common_http_fields[] = {
88
+ # define f(N) { (sizeof(N) - 1), N, Qnil }
89
+ f("ACCEPT"),
90
+ f("ACCEPT_CHARSET"),
91
+ f("ACCEPT_ENCODING"),
92
+ f("ACCEPT_LANGUAGE"),
93
+ f("ALLOW"),
94
+ f("AUTHORIZATION"),
95
+ f("CACHE_CONTROL"),
96
+ f("CONNECTION"),
97
+ f("CONTENT_ENCODING"),
98
+ f("CONTENT_LENGTH"),
99
+ f("CONTENT_TYPE"),
100
+ f("COOKIE"),
101
+ f("DATE"),
102
+ f("EXPECT"),
103
+ f("FROM"),
104
+ f("HOST"),
105
+ f("IF_MATCH"),
106
+ f("IF_MODIFIED_SINCE"),
107
+ f("IF_NONE_MATCH"),
108
+ f("IF_RANGE"),
109
+ f("IF_UNMODIFIED_SINCE"),
110
+ f("KEEP_ALIVE"), /* Firefox sends this */
111
+ f("MAX_FORWARDS"),
112
+ f("PRAGMA"),
113
+ f("PROXY_AUTHORIZATION"),
114
+ f("RANGE"),
115
+ f("REFERER"),
116
+ f("TE"),
117
+ f("TRAILER"),
118
+ f("TRANSFER_ENCODING"),
119
+ f("UPGRADE"),
120
+ f("USER_AGENT"),
121
+ f("VIA"),
122
+ f("X_FORWARDED_FOR"), /* common for proxies */
123
+ f("X_REAL_IP"), /* common for proxies */
124
+ f("WARNING")
125
+ # undef f
126
+ };
127
+
128
+ /*
129
+ * qsort(3) and bsearch(3) improve average performance slightly, but may
130
+ * not be worth it for lack of portability to certain platforms...
131
+ */
132
+ #if defined(HAVE_QSORT_BSEARCH)
133
+ /* sort by length, then by name if there's a tie */
134
+ static int common_field_cmp(const void *a, const void *b)
135
+ {
136
+ struct common_field *cfa = (struct common_field *)a;
137
+ struct common_field *cfb = (struct common_field *)b;
138
+ signed long diff = cfa->len - cfb->len;
139
+ return diff ? diff : memcmp(cfa->name, cfb->name, cfa->len);
140
+ }
141
+ #endif /* HAVE_QSORT_BSEARCH */
142
+
143
+ static void init_common_fields(void)
144
+ {
145
+ int i;
146
+ struct common_field *cf = common_http_fields;
147
+ char tmp[256]; /* MAX_FIELD_NAME_LENGTH */
148
+ memcpy(tmp, HTTP_PREFIX, HTTP_PREFIX_LEN);
149
+
150
+ for(i = 0; i < ARRAY_SIZE(common_http_fields); cf++, i++) {
151
+ memcpy(tmp + HTTP_PREFIX_LEN, cf->name, cf->len + 1);
152
+ cf->value = rb_obj_freeze(rb_str_new(tmp, HTTP_PREFIX_LEN + cf->len));
153
+ rb_global_variable(&cf->value);
154
+ }
155
+
156
+ #if defined(HAVE_QSORT_BSEARCH)
157
+ qsort(common_http_fields,
158
+ ARRAY_SIZE(common_http_fields),
159
+ sizeof(struct common_field),
160
+ common_field_cmp);
161
+ #endif /* HAVE_QSORT_BSEARCH */
162
+ }
163
+
164
+ static VALUE find_common_field_value(const char *field, size_t flen)
165
+ {
166
+ #if defined(HAVE_QSORT_BSEARCH)
167
+ struct common_field key;
168
+ struct common_field *found;
169
+ key.name = field;
170
+ key.len = (signed long)flen;
171
+ found = (struct common_field *)bsearch(&key, common_http_fields,
172
+ ARRAY_SIZE(common_http_fields),
173
+ sizeof(struct common_field),
174
+ common_field_cmp);
175
+ return found ? found->value : Qnil;
176
+ #else /* !HAVE_QSORT_BSEARCH */
177
+ int i;
178
+ struct common_field *cf = common_http_fields;
179
+ for(i = 0; i < ARRAY_SIZE(common_http_fields); i++, cf++) {
180
+ if (cf->len == flen && !memcmp(cf->name, field, flen))
181
+ return cf->value;
182
+ }
183
+ return Qnil;
184
+ #endif /* !HAVE_QSORT_BSEARCH */
185
+ }
62
186
 
63
187
  void http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen)
64
188
  {
65
- char *ch, *end;
66
189
  VALUE req = (VALUE)data;
67
190
  VALUE v = Qnil;
68
191
  VALUE f = Qnil;
@@ -71,15 +194,25 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s
71
194
  VALIDATE_MAX_LENGTH(vlen, FIELD_VALUE);
72
195
 
73
196
  v = rb_str_new(value, vlen);
74
- f = rb_str_dup(global_http_prefix);
75
- f = rb_str_buf_cat(f, field, flen);
76
197
 
77
- for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
78
- if(*ch == '-') {
79
- *ch = '_';
80
- } else {
81
- *ch = toupper(*ch);
82
- }
198
+ f = find_common_field_value(field, flen);
199
+
200
+ if (f == Qnil) {
201
+ /*
202
+ * We got a strange header that we don't have a memoized value for.
203
+ * Fallback to creating a new string to use as a hash key.
204
+ *
205
+ * using rb_str_new(NULL, len) here is faster than rb_str_buf_new(len)
206
+ * in my testing, because: there's no minimum allocation length (and
207
+ * no check for it, either), RSTRING_LEN(f) does not need to be
208
+ * written twice, and and RSTRING_PTR(f) will already be
209
+ * null-terminated for us.
210
+ */
211
+ f = rb_str_new(NULL, HTTP_PREFIX_LEN + flen);
212
+ memcpy(RSTRING_PTR(f), HTTP_PREFIX, HTTP_PREFIX_LEN);
213
+ memcpy(RSTRING_PTR(f) + HTTP_PREFIX_LEN, field, flen);
214
+ assert(*(RSTRING_PTR(f) + RSTRING_LEN(f)) == '\0'); /* paranoia */
215
+ /* fprintf(stderr, "UNKNOWN HEADER <%s>\n", RSTRING_PTR(f)); */
83
216
  }
84
217
 
85
218
  rb_hash_aset(req, f, v);
@@ -168,13 +301,12 @@ void header_done(void *data, const char *at, size_t length)
168
301
 
169
302
  rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
170
303
  if((temp = rb_hash_aref(req, global_http_host)) != Qnil) {
171
- /* ruby better close strings off with a '\0' dammit */
172
- colon = strchr(RSTRING(temp)->ptr, ':');
304
+ colon = memchr(RSTRING_PTR(temp), ':', RSTRING_LEN(temp));
173
305
  if(colon != NULL) {
174
- rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr));
306
+ rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));
175
307
  rb_hash_aset(req, global_server_port,
176
- rb_str_substr(temp, colon - RSTRING(temp)->ptr+1,
177
- RSTRING(temp)->len));
308
+ rb_str_substr(temp, colon - RSTRING_PTR(temp)+1,
309
+ RSTRING_LEN(temp)));
178
310
  } else {
179
311
  rb_hash_aset(req, global_server_name, temp);
180
312
  rb_hash_aset(req, global_server_port, global_port_80);
@@ -295,8 +427,8 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
295
427
  DATA_GET(self, http_parser, http);
296
428
 
297
429
  from = FIX2INT(start);
298
- dptr = RSTRING(data)->ptr;
299
- dlen = RSTRING(data)->len;
430
+ dptr = RSTRING_PTR(data);
431
+ dlen = RSTRING_LEN(data);
300
432
 
301
433
  if(from >= dlen) {
302
434
  rb_raise(eHttpParserError, "Requested start is after data buffer end.");
@@ -366,7 +498,6 @@ void Init_http11()
366
498
 
367
499
  mMongrel = rb_define_module("Mongrel");
368
500
 
369
- DEF_GLOBAL(http_prefix, "HTTP_");
370
501
  DEF_GLOBAL(request_method, "REQUEST_METHOD");
371
502
  DEF_GLOBAL(request_uri, "REQUEST_URI");
372
503
  DEF_GLOBAL(fragment, "FRAGMENT");
@@ -384,7 +515,7 @@ void Init_http11()
384
515
  DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
385
516
  DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
386
517
  DEF_GLOBAL(http_host, "HTTP_HOST");
387
- DEF_GLOBAL(mongrel_version, "Mongrel 1.1.5"); /* XXX Why is this defined here? */
518
+ DEF_GLOBAL(mongrel_version, "Mongrel 1.2.0.pre2"); /* XXX Why is this defined here? */
388
519
  DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
389
520
  DEF_GLOBAL(port_80, "80");
390
521
 
@@ -399,4 +530,5 @@ void Init_http11()
399
530
  rb_define_method(cHttpParser, "error?", HttpParser_has_error,0);
400
531
  rb_define_method(cHttpParser, "finished?", HttpParser_is_finished,0);
401
532
  rb_define_method(cHttpParser, "nread", HttpParser_nread,0);
533
+ init_common_fields();
402
534
  }
@@ -1,4 +1,4 @@
1
- #line 1 "http11_parser.rl"
1
+ #line 1 "ext/http11/http11_parser.rl"
2
2
  /**
3
3
  * Copyright (c) 2005 Zed A. Shaw
4
4
  * You can redistribute it and/or modify it under the same terms as Ruby.
@@ -10,34 +10,46 @@
10
10
  #include <ctype.h>
11
11
  #include <string.h>
12
12
 
13
+ /*
14
+ * capitalizes all lower-case ASCII characters,
15
+ * converts dashes to underscores.
16
+ */
17
+ static void snake_upcase_char(char *c)
18
+ {
19
+ if (*c >= 'a' && *c <= 'z')
20
+ *c &= ~0x20;
21
+ else if (*c == '-')
22
+ *c = '_';
23
+ }
24
+
13
25
  #define LEN(AT, FPC) (FPC - buffer - parser->AT)
14
26
  #define MARK(M,FPC) (parser->M = (FPC) - buffer)
15
27
  #define PTR_TO(F) (buffer + parser->F)
16
28
 
17
29
  /** Machine **/
18
30
 
19
- #line 74 "http11_parser.rl"
31
+ #line 87 "ext/http11/http11_parser.rl"
20
32
 
21
33
 
22
34
  /** Data **/
23
35
 
24
- #line 25 "http11_parser.c"
36
+ #line 37 "ext/http11/http11_parser.c"
25
37
  static const int http_parser_start = 1;
26
38
  static const int http_parser_first_final = 57;
27
39
  static const int http_parser_error = 0;
28
40
 
29
41
  static const int http_parser_en_main = 1;
30
42
 
31
- #line 78 "http11_parser.rl"
43
+ #line 91 "ext/http11/http11_parser.rl"
32
44
 
33
45
  int http_parser_init(http_parser *parser) {
34
46
  int cs = 0;
35
47
 
36
- #line 37 "http11_parser.c"
48
+ #line 49 "ext/http11/http11_parser.c"
37
49
  {
38
50
  cs = http_parser_start;
39
51
  }
40
- #line 82 "http11_parser.rl"
52
+ #line 95 "ext/http11/http11_parser.rl"
41
53
  parser->cs = cs;
42
54
  parser->body_start = 0;
43
55
  parser->content_len = 0;
@@ -60,15 +72,14 @@ size_t http_parser_execute(http_parser *parser, const char *buffer, size_t len,
60
72
  p = buffer+off;
61
73
  pe = buffer+len;
62
74
 
63
- assert(*pe == '\0' && "pointer does not end on NUL");
75
+ /* assert(*pe == '\0' && "pointer does not end on NUL"); */
64
76
  assert(pe - p == len - off && "pointers aren't same distance");
65
77
 
66
-
67
78
 
68
- #line 69 "http11_parser.c"
79
+ #line 80 "ext/http11/http11_parser.c"
69
80
  {
70
81
  if ( p == pe )
71
- goto _out;
82
+ goto _test_eof;
72
83
  switch ( cs )
73
84
  {
74
85
  case 1:
@@ -86,16 +97,17 @@ case 1:
86
97
  goto tr0;
87
98
  goto st0;
88
99
  st0:
89
- goto _out0;
100
+ cs = 0;
101
+ goto _out;
90
102
  tr0:
91
- #line 22 "http11_parser.rl"
103
+ #line 34 "ext/http11/http11_parser.rl"
92
104
  {MARK(mark, p); }
93
105
  goto st2;
94
106
  st2:
95
107
  if ( ++p == pe )
96
- goto _out2;
108
+ goto _test_eof2;
97
109
  case 2:
98
- #line 99 "http11_parser.c"
110
+ #line 111 "ext/http11/http11_parser.c"
99
111
  switch( (*p) ) {
100
112
  case 32: goto tr2;
101
113
  case 36: goto st38;
@@ -111,7 +123,7 @@ case 2:
111
123
  goto st38;
112
124
  goto st0;
113
125
  tr2:
114
- #line 36 "http11_parser.rl"
126
+ #line 49 "ext/http11/http11_parser.rl"
115
127
  {
116
128
  if(parser->request_method != NULL)
117
129
  parser->request_method(parser->data, PTR_TO(mark), LEN(mark, p));
@@ -119,9 +131,9 @@ tr2:
119
131
  goto st3;
120
132
  st3:
121
133
  if ( ++p == pe )
122
- goto _out3;
134
+ goto _test_eof3;
123
135
  case 3:
124
- #line 125 "http11_parser.c"
136
+ #line 137 "ext/http11/http11_parser.c"
125
137
  switch( (*p) ) {
126
138
  case 42: goto tr4;
127
139
  case 43: goto tr5;
@@ -138,66 +150,75 @@ case 3:
138
150
  goto tr5;
139
151
  goto st0;
140
152
  tr4:
141
- #line 22 "http11_parser.rl"
153
+ #line 34 "ext/http11/http11_parser.rl"
142
154
  {MARK(mark, p); }
143
155
  goto st4;
144
156
  st4:
145
157
  if ( ++p == pe )
146
- goto _out4;
158
+ goto _test_eof4;
147
159
  case 4:
148
- #line 149 "http11_parser.c"
160
+ #line 161 "ext/http11/http11_parser.c"
149
161
  switch( (*p) ) {
150
162
  case 32: goto tr8;
151
163
  case 35: goto tr9;
152
164
  }
153
165
  goto st0;
154
166
  tr8:
155
- #line 40 "http11_parser.rl"
167
+ #line 53 "ext/http11/http11_parser.rl"
156
168
  {
157
169
  if(parser->request_uri != NULL)
158
170
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
159
171
  }
160
172
  goto st5;
161
- tr30:
162
- #line 44 "http11_parser.rl"
163
- {
173
+ tr31:
174
+ #line 34 "ext/http11/http11_parser.rl"
175
+ {MARK(mark, p); }
176
+ #line 57 "ext/http11/http11_parser.rl"
177
+ {
164
178
  if(parser->fragment != NULL)
165
179
  parser->fragment(parser->data, PTR_TO(mark), LEN(mark, p));
166
180
  }
167
181
  goto st5;
168
- tr40:
169
- #line 60 "http11_parser.rl"
182
+ tr34:
183
+ #line 57 "ext/http11/http11_parser.rl"
184
+ {
185
+ if(parser->fragment != NULL)
186
+ parser->fragment(parser->data, PTR_TO(mark), LEN(mark, p));
187
+ }
188
+ goto st5;
189
+ tr42:
190
+ #line 73 "ext/http11/http11_parser.rl"
170
191
  {
171
192
  if(parser->request_path != NULL)
172
193
  parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
173
194
  }
174
- #line 40 "http11_parser.rl"
195
+ #line 53 "ext/http11/http11_parser.rl"
175
196
  {
176
197
  if(parser->request_uri != NULL)
177
198
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
178
199
  }
179
200
  goto st5;
180
- tr51:
181
- #line 49 "http11_parser.rl"
201
+ tr53:
202
+ #line 62 "ext/http11/http11_parser.rl"
182
203
  {MARK(query_start, p); }
183
- #line 50 "http11_parser.rl"
204
+ #line 63 "ext/http11/http11_parser.rl"
184
205
  {
185
206
  if(parser->query_string != NULL)
186
207
  parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
187
208
  }
188
- #line 40 "http11_parser.rl"
209
+ #line 53 "ext/http11/http11_parser.rl"
189
210
  {
190
211
  if(parser->request_uri != NULL)
191
212
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
192
213
  }
193
214
  goto st5;
194
- tr55:
195
- #line 50 "http11_parser.rl"
215
+ tr57:
216
+ #line 63 "ext/http11/http11_parser.rl"
196
217
  {
197
218
  if(parser->query_string != NULL)
198
219
  parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
199
220
  }
200
- #line 40 "http11_parser.rl"
221
+ #line 53 "ext/http11/http11_parser.rl"
201
222
  {
202
223
  if(parser->request_uri != NULL)
203
224
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
@@ -205,55 +226,55 @@ tr55:
205
226
  goto st5;
206
227
  st5:
207
228
  if ( ++p == pe )
208
- goto _out5;
229
+ goto _test_eof5;
209
230
  case 5:
210
- #line 211 "http11_parser.c"
231
+ #line 232 "ext/http11/http11_parser.c"
211
232
  if ( (*p) == 72 )
212
233
  goto tr10;
213
234
  goto st0;
214
235
  tr10:
215
- #line 22 "http11_parser.rl"
236
+ #line 34 "ext/http11/http11_parser.rl"
216
237
  {MARK(mark, p); }
217
238
  goto st6;
218
239
  st6:
219
240
  if ( ++p == pe )
220
- goto _out6;
241
+ goto _test_eof6;
221
242
  case 6:
222
- #line 223 "http11_parser.c"
243
+ #line 244 "ext/http11/http11_parser.c"
223
244
  if ( (*p) == 84 )
224
245
  goto st7;
225
246
  goto st0;
226
247
  st7:
227
248
  if ( ++p == pe )
228
- goto _out7;
249
+ goto _test_eof7;
229
250
  case 7:
230
251
  if ( (*p) == 84 )
231
252
  goto st8;
232
253
  goto st0;
233
254
  st8:
234
255
  if ( ++p == pe )
235
- goto _out8;
256
+ goto _test_eof8;
236
257
  case 8:
237
258
  if ( (*p) == 80 )
238
259
  goto st9;
239
260
  goto st0;
240
261
  st9:
241
262
  if ( ++p == pe )
242
- goto _out9;
263
+ goto _test_eof9;
243
264
  case 9:
244
265
  if ( (*p) == 47 )
245
266
  goto st10;
246
267
  goto st0;
247
268
  st10:
248
269
  if ( ++p == pe )
249
- goto _out10;
270
+ goto _test_eof10;
250
271
  case 10:
251
272
  if ( 48 <= (*p) && (*p) <= 57 )
252
273
  goto st11;
253
274
  goto st0;
254
275
  st11:
255
276
  if ( ++p == pe )
256
- goto _out11;
277
+ goto _test_eof11;
257
278
  case 11:
258
279
  if ( (*p) == 46 )
259
280
  goto st12;
@@ -262,14 +283,14 @@ case 11:
262
283
  goto st0;
263
284
  st12:
264
285
  if ( ++p == pe )
265
- goto _out12;
286
+ goto _test_eof12;
266
287
  case 12:
267
288
  if ( 48 <= (*p) && (*p) <= 57 )
268
289
  goto st13;
269
290
  goto st0;
270
291
  st13:
271
292
  if ( ++p == pe )
272
- goto _out13;
293
+ goto _test_eof13;
273
294
  case 13:
274
295
  if ( (*p) == 13 )
275
296
  goto tr18;
@@ -277,15 +298,25 @@ case 13:
277
298
  goto st13;
278
299
  goto st0;
279
300
  tr18:
280
- #line 55 "http11_parser.rl"
301
+ #line 68 "ext/http11/http11_parser.rl"
281
302
  {
282
303
  if(parser->http_version != NULL)
283
304
  parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p));
284
305
  }
285
306
  goto st14;
286
307
  tr26:
287
- #line 31 "http11_parser.rl"
288
- {
308
+ #line 43 "ext/http11/http11_parser.rl"
309
+ { MARK(mark, p); }
310
+ #line 44 "ext/http11/http11_parser.rl"
311
+ {
312
+ if(parser->http_field != NULL) {
313
+ parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
314
+ }
315
+ }
316
+ goto st14;
317
+ tr29:
318
+ #line 44 "ext/http11/http11_parser.rl"
319
+ {
289
320
  if(parser->http_field != NULL) {
290
321
  parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
291
322
  }
@@ -293,15 +324,15 @@ tr26:
293
324
  goto st14;
294
325
  st14:
295
326
  if ( ++p == pe )
296
- goto _out14;
327
+ goto _test_eof14;
297
328
  case 14:
298
- #line 299 "http11_parser.c"
329
+ #line 330 "ext/http11/http11_parser.c"
299
330
  if ( (*p) == 10 )
300
331
  goto st15;
301
332
  goto st0;
302
333
  st15:
303
334
  if ( ++p == pe )
304
- goto _out15;
335
+ goto _test_eof15;
305
336
  case 15:
306
337
  switch( (*p) ) {
307
338
  case 13: goto st16;
@@ -329,131 +360,137 @@ case 15:
329
360
  goto st0;
330
361
  st16:
331
362
  if ( ++p == pe )
332
- goto _out16;
363
+ goto _test_eof16;
333
364
  case 16:
334
365
  if ( (*p) == 10 )
335
366
  goto tr22;
336
367
  goto st0;
337
368
  tr22:
338
- #line 65 "http11_parser.rl"
369
+ #line 78 "ext/http11/http11_parser.rl"
339
370
  {
340
371
  parser->body_start = p - buffer + 1;
341
372
  if(parser->header_done != NULL)
342
373
  parser->header_done(parser->data, p + 1, pe - p - 1);
343
- goto _out57;
374
+ {p++; cs = 57; goto _out;}
344
375
  }
345
376
  goto st57;
346
377
  st57:
347
378
  if ( ++p == pe )
348
- goto _out57;
379
+ goto _test_eof57;
349
380
  case 57:
350
- #line 351 "http11_parser.c"
381
+ #line 382 "ext/http11/http11_parser.c"
351
382
  goto st0;
352
383
  tr21:
353
- #line 25 "http11_parser.rl"
384
+ #line 37 "ext/http11/http11_parser.rl"
354
385
  { MARK(field_start, p); }
386
+ #line 38 "ext/http11/http11_parser.rl"
387
+ { snake_upcase_char((char *)p); }
388
+ goto st17;
389
+ tr23:
390
+ #line 38 "ext/http11/http11_parser.rl"
391
+ { snake_upcase_char((char *)p); }
355
392
  goto st17;
356
393
  st17:
357
394
  if ( ++p == pe )
358
- goto _out17;
395
+ goto _test_eof17;
359
396
  case 17:
360
- #line 361 "http11_parser.c"
397
+ #line 398 "ext/http11/http11_parser.c"
361
398
  switch( (*p) ) {
362
- case 33: goto st17;
399
+ case 33: goto tr23;
363
400
  case 58: goto tr24;
364
- case 124: goto st17;
365
- case 126: goto st17;
401
+ case 124: goto tr23;
402
+ case 126: goto tr23;
366
403
  }
367
404
  if ( (*p) < 45 ) {
368
405
  if ( (*p) > 39 ) {
369
406
  if ( 42 <= (*p) && (*p) <= 43 )
370
- goto st17;
407
+ goto tr23;
371
408
  } else if ( (*p) >= 35 )
372
- goto st17;
409
+ goto tr23;
373
410
  } else if ( (*p) > 46 ) {
374
411
  if ( (*p) < 65 ) {
375
412
  if ( 48 <= (*p) && (*p) <= 57 )
376
- goto st17;
413
+ goto tr23;
377
414
  } else if ( (*p) > 90 ) {
378
415
  if ( 94 <= (*p) && (*p) <= 122 )
379
- goto st17;
416
+ goto tr23;
380
417
  } else
381
- goto st17;
418
+ goto tr23;
382
419
  } else
383
- goto st17;
420
+ goto tr23;
384
421
  goto st0;
385
422
  tr24:
386
- #line 26 "http11_parser.rl"
423
+ #line 39 "ext/http11/http11_parser.rl"
387
424
  {
388
425
  parser->field_len = LEN(field_start, p);
389
426
  }
390
427
  goto st18;
391
428
  tr27:
392
- #line 30 "http11_parser.rl"
429
+ #line 43 "ext/http11/http11_parser.rl"
393
430
  { MARK(mark, p); }
394
431
  goto st18;
395
432
  st18:
396
433
  if ( ++p == pe )
397
- goto _out18;
434
+ goto _test_eof18;
398
435
  case 18:
399
- #line 400 "http11_parser.c"
436
+ #line 437 "ext/http11/http11_parser.c"
400
437
  switch( (*p) ) {
401
438
  case 13: goto tr26;
402
439
  case 32: goto tr27;
403
440
  }
404
441
  goto tr25;
405
442
  tr25:
406
- #line 30 "http11_parser.rl"
443
+ #line 43 "ext/http11/http11_parser.rl"
407
444
  { MARK(mark, p); }
408
445
  goto st19;
409
446
  st19:
410
447
  if ( ++p == pe )
411
- goto _out19;
448
+ goto _test_eof19;
412
449
  case 19:
413
- #line 414 "http11_parser.c"
450
+ #line 451 "ext/http11/http11_parser.c"
414
451
  if ( (*p) == 13 )
415
- goto tr26;
452
+ goto tr29;
416
453
  goto st19;
417
454
  tr9:
418
- #line 40 "http11_parser.rl"
455
+ #line 53 "ext/http11/http11_parser.rl"
419
456
  {
420
457
  if(parser->request_uri != NULL)
421
458
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
422
459
  }
423
460
  goto st20;
424
- tr41:
425
- #line 60 "http11_parser.rl"
461
+ tr43:
462
+ #line 73 "ext/http11/http11_parser.rl"
426
463
  {
427
464
  if(parser->request_path != NULL)
428
465
  parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
429
466
  }
430
- #line 40 "http11_parser.rl"
467
+ #line 53 "ext/http11/http11_parser.rl"
431
468
  {
432
469
  if(parser->request_uri != NULL)
433
470
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
434
471
  }
435
472
  goto st20;
436
- tr52:
437
- #line 49 "http11_parser.rl"
473
+ tr54:
474
+ #line 62 "ext/http11/http11_parser.rl"
438
475
  {MARK(query_start, p); }
439
- #line 50 "http11_parser.rl"
476
+ #line 63 "ext/http11/http11_parser.rl"
440
477
  {
441
478
  if(parser->query_string != NULL)
442
479
  parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
443
480
  }
444
- #line 40 "http11_parser.rl"
481
+ #line 53 "ext/http11/http11_parser.rl"
445
482
  {
446
483
  if(parser->request_uri != NULL)
447
484
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
448
485
  }
449
486
  goto st20;
450
- tr56:
451
- #line 50 "http11_parser.rl"
487
+ tr58:
488
+ #line 63 "ext/http11/http11_parser.rl"
452
489
  {
453
490
  if(parser->query_string != NULL)
454
491
  parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
455
492
  }
456
- #line 40 "http11_parser.rl"
493
+ #line 53 "ext/http11/http11_parser.rl"
457
494
  {
458
495
  if(parser->request_uri != NULL)
459
496
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
@@ -461,12 +498,12 @@ tr56:
461
498
  goto st20;
462
499
  st20:
463
500
  if ( ++p == pe )
464
- goto _out20;
501
+ goto _test_eof20;
465
502
  case 20:
466
- #line 467 "http11_parser.c"
503
+ #line 504 "ext/http11/http11_parser.c"
467
504
  switch( (*p) ) {
468
- case 32: goto tr30;
469
- case 37: goto tr31;
505
+ case 32: goto tr31;
506
+ case 37: goto tr32;
470
507
  case 60: goto st0;
471
508
  case 62: goto st0;
472
509
  case 127: goto st0;
@@ -476,18 +513,18 @@ case 20:
476
513
  goto st0;
477
514
  } else if ( (*p) >= 0 )
478
515
  goto st0;
479
- goto tr29;
480
- tr29:
481
- #line 22 "http11_parser.rl"
516
+ goto tr30;
517
+ tr30:
518
+ #line 34 "ext/http11/http11_parser.rl"
482
519
  {MARK(mark, p); }
483
520
  goto st21;
484
521
  st21:
485
522
  if ( ++p == pe )
486
- goto _out21;
523
+ goto _test_eof21;
487
524
  case 21:
488
- #line 489 "http11_parser.c"
525
+ #line 526 "ext/http11/http11_parser.c"
489
526
  switch( (*p) ) {
490
- case 32: goto tr30;
527
+ case 32: goto tr34;
491
528
  case 37: goto st22;
492
529
  case 60: goto st0;
493
530
  case 62: goto st0;
@@ -499,15 +536,15 @@ case 21:
499
536
  } else if ( (*p) >= 0 )
500
537
  goto st0;
501
538
  goto st21;
502
- tr31:
503
- #line 22 "http11_parser.rl"
539
+ tr32:
540
+ #line 34 "ext/http11/http11_parser.rl"
504
541
  {MARK(mark, p); }
505
542
  goto st22;
506
543
  st22:
507
544
  if ( ++p == pe )
508
- goto _out22;
545
+ goto _test_eof22;
509
546
  case 22:
510
- #line 511 "http11_parser.c"
547
+ #line 548 "ext/http11/http11_parser.c"
511
548
  if ( (*p) < 65 ) {
512
549
  if ( 48 <= (*p) && (*p) <= 57 )
513
550
  goto st23;
@@ -519,7 +556,7 @@ case 22:
519
556
  goto st0;
520
557
  st23:
521
558
  if ( ++p == pe )
522
- goto _out23;
559
+ goto _test_eof23;
523
560
  case 23:
524
561
  if ( (*p) < 65 ) {
525
562
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -531,14 +568,14 @@ case 23:
531
568
  goto st21;
532
569
  goto st0;
533
570
  tr5:
534
- #line 22 "http11_parser.rl"
571
+ #line 34 "ext/http11/http11_parser.rl"
535
572
  {MARK(mark, p); }
536
573
  goto st24;
537
574
  st24:
538
575
  if ( ++p == pe )
539
- goto _out24;
576
+ goto _test_eof24;
540
577
  case 24:
541
- #line 542 "http11_parser.c"
578
+ #line 579 "ext/http11/http11_parser.c"
542
579
  switch( (*p) ) {
543
580
  case 43: goto st24;
544
581
  case 58: goto st25;
@@ -556,14 +593,14 @@ case 24:
556
593
  goto st24;
557
594
  goto st0;
558
595
  tr7:
559
- #line 22 "http11_parser.rl"
596
+ #line 34 "ext/http11/http11_parser.rl"
560
597
  {MARK(mark, p); }
561
598
  goto st25;
562
599
  st25:
563
600
  if ( ++p == pe )
564
- goto _out25;
601
+ goto _test_eof25;
565
602
  case 25:
566
- #line 567 "http11_parser.c"
603
+ #line 604 "ext/http11/http11_parser.c"
567
604
  switch( (*p) ) {
568
605
  case 32: goto tr8;
569
606
  case 34: goto st0;
@@ -578,7 +615,7 @@ case 25:
578
615
  goto st25;
579
616
  st26:
580
617
  if ( ++p == pe )
581
- goto _out26;
618
+ goto _test_eof26;
582
619
  case 26:
583
620
  if ( (*p) < 65 ) {
584
621
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -591,7 +628,7 @@ case 26:
591
628
  goto st0;
592
629
  st27:
593
630
  if ( ++p == pe )
594
- goto _out27;
631
+ goto _test_eof27;
595
632
  case 27:
596
633
  if ( (*p) < 65 ) {
597
634
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -603,23 +640,23 @@ case 27:
603
640
  goto st25;
604
641
  goto st0;
605
642
  tr6:
606
- #line 22 "http11_parser.rl"
643
+ #line 34 "ext/http11/http11_parser.rl"
607
644
  {MARK(mark, p); }
608
645
  goto st28;
609
646
  st28:
610
647
  if ( ++p == pe )
611
- goto _out28;
648
+ goto _test_eof28;
612
649
  case 28:
613
- #line 614 "http11_parser.c"
650
+ #line 651 "ext/http11/http11_parser.c"
614
651
  switch( (*p) ) {
615
- case 32: goto tr40;
652
+ case 32: goto tr42;
616
653
  case 34: goto st0;
617
- case 35: goto tr41;
654
+ case 35: goto tr43;
618
655
  case 37: goto st29;
619
- case 59: goto tr43;
656
+ case 59: goto tr45;
620
657
  case 60: goto st0;
621
658
  case 62: goto st0;
622
- case 63: goto tr44;
659
+ case 63: goto tr46;
623
660
  case 127: goto st0;
624
661
  }
625
662
  if ( 0 <= (*p) && (*p) <= 31 )
@@ -627,7 +664,7 @@ case 28:
627
664
  goto st28;
628
665
  st29:
629
666
  if ( ++p == pe )
630
- goto _out29;
667
+ goto _test_eof29;
631
668
  case 29:
632
669
  if ( (*p) < 65 ) {
633
670
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -640,7 +677,7 @@ case 29:
640
677
  goto st0;
641
678
  st30:
642
679
  if ( ++p == pe )
643
- goto _out30;
680
+ goto _test_eof30;
644
681
  case 30:
645
682
  if ( (*p) < 65 ) {
646
683
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -651,8 +688,8 @@ case 30:
651
688
  } else
652
689
  goto st28;
653
690
  goto st0;
654
- tr43:
655
- #line 60 "http11_parser.rl"
691
+ tr45:
692
+ #line 73 "ext/http11/http11_parser.rl"
656
693
  {
657
694
  if(parser->request_path != NULL)
658
695
  parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
@@ -660,9 +697,9 @@ tr43:
660
697
  goto st31;
661
698
  st31:
662
699
  if ( ++p == pe )
663
- goto _out31;
700
+ goto _test_eof31;
664
701
  case 31:
665
- #line 666 "http11_parser.c"
702
+ #line 703 "ext/http11/http11_parser.c"
666
703
  switch( (*p) ) {
667
704
  case 32: goto tr8;
668
705
  case 34: goto st0;
@@ -678,7 +715,7 @@ case 31:
678
715
  goto st31;
679
716
  st32:
680
717
  if ( ++p == pe )
681
- goto _out32;
718
+ goto _test_eof32;
682
719
  case 32:
683
720
  if ( (*p) < 65 ) {
684
721
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -691,7 +728,7 @@ case 32:
691
728
  goto st0;
692
729
  st33:
693
730
  if ( ++p == pe )
694
- goto _out33;
731
+ goto _test_eof33;
695
732
  case 33:
696
733
  if ( (*p) < 65 ) {
697
734
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -702,8 +739,8 @@ case 33:
702
739
  } else
703
740
  goto st31;
704
741
  goto st0;
705
- tr44:
706
- #line 60 "http11_parser.rl"
742
+ tr46:
743
+ #line 73 "ext/http11/http11_parser.rl"
707
744
  {
708
745
  if(parser->request_path != NULL)
709
746
  parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
@@ -711,34 +748,34 @@ tr44:
711
748
  goto st34;
712
749
  st34:
713
750
  if ( ++p == pe )
714
- goto _out34;
751
+ goto _test_eof34;
715
752
  case 34:
716
- #line 717 "http11_parser.c"
753
+ #line 754 "ext/http11/http11_parser.c"
717
754
  switch( (*p) ) {
718
- case 32: goto tr51;
755
+ case 32: goto tr53;
719
756
  case 34: goto st0;
720
- case 35: goto tr52;
721
- case 37: goto tr53;
757
+ case 35: goto tr54;
758
+ case 37: goto tr55;
722
759
  case 60: goto st0;
723
760
  case 62: goto st0;
724
761
  case 127: goto st0;
725
762
  }
726
763
  if ( 0 <= (*p) && (*p) <= 31 )
727
764
  goto st0;
728
- goto tr50;
729
- tr50:
730
- #line 49 "http11_parser.rl"
765
+ goto tr52;
766
+ tr52:
767
+ #line 62 "ext/http11/http11_parser.rl"
731
768
  {MARK(query_start, p); }
732
769
  goto st35;
733
770
  st35:
734
771
  if ( ++p == pe )
735
- goto _out35;
772
+ goto _test_eof35;
736
773
  case 35:
737
- #line 738 "http11_parser.c"
774
+ #line 775 "ext/http11/http11_parser.c"
738
775
  switch( (*p) ) {
739
- case 32: goto tr55;
776
+ case 32: goto tr57;
740
777
  case 34: goto st0;
741
- case 35: goto tr56;
778
+ case 35: goto tr58;
742
779
  case 37: goto st36;
743
780
  case 60: goto st0;
744
781
  case 62: goto st0;
@@ -747,15 +784,15 @@ case 35:
747
784
  if ( 0 <= (*p) && (*p) <= 31 )
748
785
  goto st0;
749
786
  goto st35;
750
- tr53:
751
- #line 49 "http11_parser.rl"
787
+ tr55:
788
+ #line 62 "ext/http11/http11_parser.rl"
752
789
  {MARK(query_start, p); }
753
790
  goto st36;
754
791
  st36:
755
792
  if ( ++p == pe )
756
- goto _out36;
793
+ goto _test_eof36;
757
794
  case 36:
758
- #line 759 "http11_parser.c"
795
+ #line 796 "ext/http11/http11_parser.c"
759
796
  if ( (*p) < 65 ) {
760
797
  if ( 48 <= (*p) && (*p) <= 57 )
761
798
  goto st37;
@@ -767,7 +804,7 @@ case 36:
767
804
  goto st0;
768
805
  st37:
769
806
  if ( ++p == pe )
770
- goto _out37;
807
+ goto _test_eof37;
771
808
  case 37:
772
809
  if ( (*p) < 65 ) {
773
810
  if ( 48 <= (*p) && (*p) <= 57 )
@@ -780,7 +817,7 @@ case 37:
780
817
  goto st0;
781
818
  st38:
782
819
  if ( ++p == pe )
783
- goto _out38;
820
+ goto _test_eof38;
784
821
  case 38:
785
822
  switch( (*p) ) {
786
823
  case 32: goto tr2;
@@ -798,7 +835,7 @@ case 38:
798
835
  goto st0;
799
836
  st39:
800
837
  if ( ++p == pe )
801
- goto _out39;
838
+ goto _test_eof39;
802
839
  case 39:
803
840
  switch( (*p) ) {
804
841
  case 32: goto tr2;
@@ -816,7 +853,7 @@ case 39:
816
853
  goto st0;
817
854
  st40:
818
855
  if ( ++p == pe )
819
- goto _out40;
856
+ goto _test_eof40;
820
857
  case 40:
821
858
  switch( (*p) ) {
822
859
  case 32: goto tr2;
@@ -834,7 +871,7 @@ case 40:
834
871
  goto st0;
835
872
  st41:
836
873
  if ( ++p == pe )
837
- goto _out41;
874
+ goto _test_eof41;
838
875
  case 41:
839
876
  switch( (*p) ) {
840
877
  case 32: goto tr2;
@@ -852,7 +889,7 @@ case 41:
852
889
  goto st0;
853
890
  st42:
854
891
  if ( ++p == pe )
855
- goto _out42;
892
+ goto _test_eof42;
856
893
  case 42:
857
894
  switch( (*p) ) {
858
895
  case 32: goto tr2;
@@ -870,7 +907,7 @@ case 42:
870
907
  goto st0;
871
908
  st43:
872
909
  if ( ++p == pe )
873
- goto _out43;
910
+ goto _test_eof43;
874
911
  case 43:
875
912
  switch( (*p) ) {
876
913
  case 32: goto tr2;
@@ -888,7 +925,7 @@ case 43:
888
925
  goto st0;
889
926
  st44:
890
927
  if ( ++p == pe )
891
- goto _out44;
928
+ goto _test_eof44;
892
929
  case 44:
893
930
  switch( (*p) ) {
894
931
  case 32: goto tr2;
@@ -906,7 +943,7 @@ case 44:
906
943
  goto st0;
907
944
  st45:
908
945
  if ( ++p == pe )
909
- goto _out45;
946
+ goto _test_eof45;
910
947
  case 45:
911
948
  switch( (*p) ) {
912
949
  case 32: goto tr2;
@@ -924,7 +961,7 @@ case 45:
924
961
  goto st0;
925
962
  st46:
926
963
  if ( ++p == pe )
927
- goto _out46;
964
+ goto _test_eof46;
928
965
  case 46:
929
966
  switch( (*p) ) {
930
967
  case 32: goto tr2;
@@ -942,7 +979,7 @@ case 46:
942
979
  goto st0;
943
980
  st47:
944
981
  if ( ++p == pe )
945
- goto _out47;
982
+ goto _test_eof47;
946
983
  case 47:
947
984
  switch( (*p) ) {
948
985
  case 32: goto tr2;
@@ -960,7 +997,7 @@ case 47:
960
997
  goto st0;
961
998
  st48:
962
999
  if ( ++p == pe )
963
- goto _out48;
1000
+ goto _test_eof48;
964
1001
  case 48:
965
1002
  switch( (*p) ) {
966
1003
  case 32: goto tr2;
@@ -978,7 +1015,7 @@ case 48:
978
1015
  goto st0;
979
1016
  st49:
980
1017
  if ( ++p == pe )
981
- goto _out49;
1018
+ goto _test_eof49;
982
1019
  case 49:
983
1020
  switch( (*p) ) {
984
1021
  case 32: goto tr2;
@@ -996,7 +1033,7 @@ case 49:
996
1033
  goto st0;
997
1034
  st50:
998
1035
  if ( ++p == pe )
999
- goto _out50;
1036
+ goto _test_eof50;
1000
1037
  case 50:
1001
1038
  switch( (*p) ) {
1002
1039
  case 32: goto tr2;
@@ -1014,7 +1051,7 @@ case 50:
1014
1051
  goto st0;
1015
1052
  st51:
1016
1053
  if ( ++p == pe )
1017
- goto _out51;
1054
+ goto _test_eof51;
1018
1055
  case 51:
1019
1056
  switch( (*p) ) {
1020
1057
  case 32: goto tr2;
@@ -1032,7 +1069,7 @@ case 51:
1032
1069
  goto st0;
1033
1070
  st52:
1034
1071
  if ( ++p == pe )
1035
- goto _out52;
1072
+ goto _test_eof52;
1036
1073
  case 52:
1037
1074
  switch( (*p) ) {
1038
1075
  case 32: goto tr2;
@@ -1050,7 +1087,7 @@ case 52:
1050
1087
  goto st0;
1051
1088
  st53:
1052
1089
  if ( ++p == pe )
1053
- goto _out53;
1090
+ goto _test_eof53;
1054
1091
  case 53:
1055
1092
  switch( (*p) ) {
1056
1093
  case 32: goto tr2;
@@ -1068,7 +1105,7 @@ case 53:
1068
1105
  goto st0;
1069
1106
  st54:
1070
1107
  if ( ++p == pe )
1071
- goto _out54;
1108
+ goto _test_eof54;
1072
1109
  case 54:
1073
1110
  switch( (*p) ) {
1074
1111
  case 32: goto tr2;
@@ -1086,7 +1123,7 @@ case 54:
1086
1123
  goto st0;
1087
1124
  st55:
1088
1125
  if ( ++p == pe )
1089
- goto _out55;
1126
+ goto _test_eof55;
1090
1127
  case 55:
1091
1128
  switch( (*p) ) {
1092
1129
  case 32: goto tr2;
@@ -1104,75 +1141,76 @@ case 55:
1104
1141
  goto st0;
1105
1142
  st56:
1106
1143
  if ( ++p == pe )
1107
- goto _out56;
1144
+ goto _test_eof56;
1108
1145
  case 56:
1109
1146
  if ( (*p) == 32 )
1110
1147
  goto tr2;
1111
1148
  goto st0;
1112
1149
  }
1113
- _out0: cs = 0; goto _out;
1114
- _out2: cs = 2; goto _out;
1115
- _out3: cs = 3; goto _out;
1116
- _out4: cs = 4; goto _out;
1117
- _out5: cs = 5; goto _out;
1118
- _out6: cs = 6; goto _out;
1119
- _out7: cs = 7; goto _out;
1120
- _out8: cs = 8; goto _out;
1121
- _out9: cs = 9; goto _out;
1122
- _out10: cs = 10; goto _out;
1123
- _out11: cs = 11; goto _out;
1124
- _out12: cs = 12; goto _out;
1125
- _out13: cs = 13; goto _out;
1126
- _out14: cs = 14; goto _out;
1127
- _out15: cs = 15; goto _out;
1128
- _out16: cs = 16; goto _out;
1129
- _out57: cs = 57; goto _out;
1130
- _out17: cs = 17; goto _out;
1131
- _out18: cs = 18; goto _out;
1132
- _out19: cs = 19; goto _out;
1133
- _out20: cs = 20; goto _out;
1134
- _out21: cs = 21; goto _out;
1135
- _out22: cs = 22; goto _out;
1136
- _out23: cs = 23; goto _out;
1137
- _out24: cs = 24; goto _out;
1138
- _out25: cs = 25; goto _out;
1139
- _out26: cs = 26; goto _out;
1140
- _out27: cs = 27; goto _out;
1141
- _out28: cs = 28; goto _out;
1142
- _out29: cs = 29; goto _out;
1143
- _out30: cs = 30; goto _out;
1144
- _out31: cs = 31; goto _out;
1145
- _out32: cs = 32; goto _out;
1146
- _out33: cs = 33; goto _out;
1147
- _out34: cs = 34; goto _out;
1148
- _out35: cs = 35; goto _out;
1149
- _out36: cs = 36; goto _out;
1150
- _out37: cs = 37; goto _out;
1151
- _out38: cs = 38; goto _out;
1152
- _out39: cs = 39; goto _out;
1153
- _out40: cs = 40; goto _out;
1154
- _out41: cs = 41; goto _out;
1155
- _out42: cs = 42; goto _out;
1156
- _out43: cs = 43; goto _out;
1157
- _out44: cs = 44; goto _out;
1158
- _out45: cs = 45; goto _out;
1159
- _out46: cs = 46; goto _out;
1160
- _out47: cs = 47; goto _out;
1161
- _out48: cs = 48; goto _out;
1162
- _out49: cs = 49; goto _out;
1163
- _out50: cs = 50; goto _out;
1164
- _out51: cs = 51; goto _out;
1165
- _out52: cs = 52; goto _out;
1166
- _out53: cs = 53; goto _out;
1167
- _out54: cs = 54; goto _out;
1168
- _out55: cs = 55; goto _out;
1169
- _out56: cs = 56; goto _out;
1150
+ _test_eof2: cs = 2; goto _test_eof;
1151
+ _test_eof3: cs = 3; goto _test_eof;
1152
+ _test_eof4: cs = 4; goto _test_eof;
1153
+ _test_eof5: cs = 5; goto _test_eof;
1154
+ _test_eof6: cs = 6; goto _test_eof;
1155
+ _test_eof7: cs = 7; goto _test_eof;
1156
+ _test_eof8: cs = 8; goto _test_eof;
1157
+ _test_eof9: cs = 9; goto _test_eof;
1158
+ _test_eof10: cs = 10; goto _test_eof;
1159
+ _test_eof11: cs = 11; goto _test_eof;
1160
+ _test_eof12: cs = 12; goto _test_eof;
1161
+ _test_eof13: cs = 13; goto _test_eof;
1162
+ _test_eof14: cs = 14; goto _test_eof;
1163
+ _test_eof15: cs = 15; goto _test_eof;
1164
+ _test_eof16: cs = 16; goto _test_eof;
1165
+ _test_eof57: cs = 57; goto _test_eof;
1166
+ _test_eof17: cs = 17; goto _test_eof;
1167
+ _test_eof18: cs = 18; goto _test_eof;
1168
+ _test_eof19: cs = 19; goto _test_eof;
1169
+ _test_eof20: cs = 20; goto _test_eof;
1170
+ _test_eof21: cs = 21; goto _test_eof;
1171
+ _test_eof22: cs = 22; goto _test_eof;
1172
+ _test_eof23: cs = 23; goto _test_eof;
1173
+ _test_eof24: cs = 24; goto _test_eof;
1174
+ _test_eof25: cs = 25; goto _test_eof;
1175
+ _test_eof26: cs = 26; goto _test_eof;
1176
+ _test_eof27: cs = 27; goto _test_eof;
1177
+ _test_eof28: cs = 28; goto _test_eof;
1178
+ _test_eof29: cs = 29; goto _test_eof;
1179
+ _test_eof30: cs = 30; goto _test_eof;
1180
+ _test_eof31: cs = 31; goto _test_eof;
1181
+ _test_eof32: cs = 32; goto _test_eof;
1182
+ _test_eof33: cs = 33; goto _test_eof;
1183
+ _test_eof34: cs = 34; goto _test_eof;
1184
+ _test_eof35: cs = 35; goto _test_eof;
1185
+ _test_eof36: cs = 36; goto _test_eof;
1186
+ _test_eof37: cs = 37; goto _test_eof;
1187
+ _test_eof38: cs = 38; goto _test_eof;
1188
+ _test_eof39: cs = 39; goto _test_eof;
1189
+ _test_eof40: cs = 40; goto _test_eof;
1190
+ _test_eof41: cs = 41; goto _test_eof;
1191
+ _test_eof42: cs = 42; goto _test_eof;
1192
+ _test_eof43: cs = 43; goto _test_eof;
1193
+ _test_eof44: cs = 44; goto _test_eof;
1194
+ _test_eof45: cs = 45; goto _test_eof;
1195
+ _test_eof46: cs = 46; goto _test_eof;
1196
+ _test_eof47: cs = 47; goto _test_eof;
1197
+ _test_eof48: cs = 48; goto _test_eof;
1198
+ _test_eof49: cs = 49; goto _test_eof;
1199
+ _test_eof50: cs = 50; goto _test_eof;
1200
+ _test_eof51: cs = 51; goto _test_eof;
1201
+ _test_eof52: cs = 52; goto _test_eof;
1202
+ _test_eof53: cs = 53; goto _test_eof;
1203
+ _test_eof54: cs = 54; goto _test_eof;
1204
+ _test_eof55: cs = 55; goto _test_eof;
1205
+ _test_eof56: cs = 56; goto _test_eof;
1170
1206
 
1207
+ _test_eof: {}
1171
1208
  _out: {}
1172
1209
  }
1173
- #line 109 "http11_parser.rl"
1210
+ #line 121 "ext/http11/http11_parser.rl"
1174
1211
 
1175
- parser->cs = cs;
1212
+ if (!http_parser_has_error(parser))
1213
+ parser->cs = cs;
1176
1214
  parser->nread += p - (buffer + off);
1177
1215
 
1178
1216
  assert(p <= pe && "buffer overflow after parsing execute");
@@ -1182,27 +1220,11 @@ case 56:
1182
1220
  assert(parser->field_len <= len && "field has length longer than whole buffer");
1183
1221
  assert(parser->field_start < len && "field starts after buffer end");
1184
1222
 
1185
- if(parser->body_start) {
1186
- /* final \r\n combo encountered so stop right here */
1187
-
1188
- #line 1189 "http11_parser.c"
1189
- #line 123 "http11_parser.rl"
1190
- parser->nread++;
1191
- }
1192
-
1193
1223
  return(parser->nread);
1194
1224
  }
1195
1225
 
1196
1226
  int http_parser_finish(http_parser *parser)
1197
1227
  {
1198
- int cs = parser->cs;
1199
-
1200
-
1201
- #line 1202 "http11_parser.c"
1202
- #line 134 "http11_parser.rl"
1203
-
1204
- parser->cs = cs;
1205
-
1206
1228
  if (http_parser_has_error(parser) ) {
1207
1229
  return -1;
1208
1230
  } else if (http_parser_is_finished(parser) ) {
@@ -1217,5 +1239,5 @@ int http_parser_has_error(http_parser *parser) {
1217
1239
  }
1218
1240
 
1219
1241
  int http_parser_is_finished(http_parser *parser) {
1220
- return parser->cs == http_parser_first_final;
1242
+ return parser->cs >= http_parser_first_final;
1221
1243
  }