mongrel 1.1.5-x86-mingw32 → 1.2.0.pre2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/History.txt +68 -0
  2. data/{Manifest → Manifest.txt} +15 -15
  3. data/{README → README.txt} +6 -0
  4. data/Rakefile +8 -0
  5. data/bin/mongrel_rails +5 -4
  6. data/examples/camping/blog.rb +0 -0
  7. data/ext/{http11_java → http11}/Http11Service.java +0 -0
  8. data/ext/http11/ext_help.h +1 -0
  9. data/ext/http11/http11.c +152 -20
  10. data/ext/http11/http11_parser.c +262 -240
  11. data/ext/http11/http11_parser.java.rl +3 -14
  12. data/ext/http11/http11_parser.rl +19 -18
  13. data/ext/http11/http11_parser_common.rl +1 -1
  14. data/ext/{http11_java → http11}/org/jruby/mongrel/Http11.java +37 -62
  15. data/ext/http11/org/jruby/mongrel/Http11Parser.java +486 -0
  16. data/lib/1.8/http11.so +0 -0
  17. data/lib/1.9/http11.so +0 -0
  18. data/lib/mongrel.rb +16 -5
  19. data/lib/mongrel/cgi.rb +2 -2
  20. data/lib/mongrel/command.rb +1 -3
  21. data/lib/mongrel/configurator.rb +5 -5
  22. data/lib/mongrel/const.rb +1 -1
  23. data/lib/mongrel/handlers.rb +5 -5
  24. data/lib/mongrel/http_request.rb +1 -1
  25. data/lib/mongrel/http_response.rb +4 -1
  26. data/lib/mongrel/rails.rb +1 -1
  27. data/tasks/gem.rake +28 -0
  28. data/tasks/native.rake +24 -0
  29. data/tasks/ragel.rake +20 -0
  30. data/test/test_conditional.rb +2 -2
  31. data/test/test_configurator.rb +4 -5
  32. data/test/test_handlers.rb +33 -24
  33. data/test/test_redirect_handler.rb +2 -3
  34. data/test/test_request_progress.rb +4 -5
  35. data/test/test_ws.rb +2 -0
  36. data/test/testhelp.rb +1 -9
  37. metadata +86 -86
  38. data.tar.gz.sig +0 -4
  39. data/CHANGELOG +0 -18
  40. data/examples/mongrel_simple_ctrl.rb +0 -92
  41. data/examples/mongrel_simple_service.rb +0 -116
  42. data/ext/http11_java/org/jruby/mongrel/Http11Parser.java +0 -572
  43. data/lib/http11.so +0 -0
  44. data/mongrel-public_cert.pem +0 -20
  45. data/mongrel.gemspec +0 -242
  46. metadata.gz.sig +0 -1
@@ -13,6 +13,7 @@ public class Http11Parser {
13
13
  action mark {parser.mark = fpc; }
14
14
 
15
15
  action start_field { parser.field_start = fpc; }
16
+ action snake_upcase_field { /* FIXME stub */ }
16
17
  action write_field {
17
18
  parser.field_len = fpc-parser.field_start;
18
19
  }
@@ -115,12 +116,12 @@ public class Http11Parser {
115
116
  public int execute(ByteList buffer, int off) {
116
117
  int p, pe;
117
118
  int cs = parser.cs;
118
- int len = buffer.realSize;
119
+ int len = buffer.length();
119
120
  assert off<=len : "offset past end of buffer";
120
121
 
121
122
  p = off;
122
123
  pe = len;
123
- byte[] data = buffer.bytes;
124
+ byte[] data = buffer.unsafeBytes();
124
125
  parser.buffer = buffer;
125
126
 
126
127
  %% write exec;
@@ -135,22 +136,10 @@ public class Http11Parser {
135
136
  assert parser.field_len <= len : "field has length longer than whole buffer";
136
137
  assert parser.field_start < len : "field starts after buffer end";
137
138
 
138
- if(parser.body_start>0) {
139
- /* final \r\n combo encountered so stop right here */
140
- %%write eof;
141
- parser.nread++;
142
- }
143
-
144
139
  return parser.nread;
145
140
  }
146
141
 
147
142
  public int finish() {
148
- int cs = parser.cs;
149
-
150
- %%write eof;
151
-
152
- parser.cs = cs;
153
-
154
143
  if(has_error()) {
155
144
  return -1;
156
145
  } else if(is_finished()) {
@@ -9,6 +9,18 @@
9
9
  #include <ctype.h>
10
10
  #include <string.h>
11
11
 
12
+ /*
13
+ * capitalizes all lower-case ASCII characters,
14
+ * converts dashes to underscores.
15
+ */
16
+ static void snake_upcase_char(char *c)
17
+ {
18
+ if (*c >= 'a' && *c <= 'z')
19
+ *c &= ~0x20;
20
+ else if (*c == '-')
21
+ *c = '_';
22
+ }
23
+
12
24
  #define LEN(AT, FPC) (FPC - buffer - parser->AT)
13
25
  #define MARK(M,FPC) (parser->M = (FPC) - buffer)
14
26
  #define PTR_TO(F) (buffer + parser->F)
@@ -23,12 +35,13 @@
23
35
 
24
36
 
25
37
  action start_field { MARK(field_start, fpc); }
38
+ action snake_upcase_field { snake_upcase_char((char *)fpc); }
26
39
  action write_field {
27
40
  parser->field_len = LEN(field_start, fpc);
28
41
  }
29
42
 
30
43
  action start_value { MARK(mark, fpc); }
31
- action write_value {
44
+ action write_value {
32
45
  if(parser->http_field != NULL) {
33
46
  parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, fpc));
34
47
  }
@@ -41,7 +54,7 @@
41
54
  if(parser->request_uri != NULL)
42
55
  parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, fpc));
43
56
  }
44
- action fragment {
57
+ action fragment {
45
58
  if(parser->fragment != NULL)
46
59
  parser->fragment(parser->data, PTR_TO(mark), LEN(mark, fpc));
47
60
  }
@@ -101,13 +114,13 @@ size_t http_parser_execute(http_parser *parser, const char *buffer, size_t len,
101
114
  p = buffer+off;
102
115
  pe = buffer+len;
103
116
 
104
- assert(*pe == '\0' && "pointer does not end on NUL");
117
+ /* assert(*pe == '\0' && "pointer does not end on NUL"); */
105
118
  assert(pe - p == len - off && "pointers aren't same distance");
106
119
 
107
-
108
120
  %% write exec;
109
121
 
110
- parser->cs = cs;
122
+ if (!http_parser_has_error(parser))
123
+ parser->cs = cs;
111
124
  parser->nread += p - (buffer + off);
112
125
 
113
126
  assert(p <= pe && "buffer overflow after parsing execute");
@@ -117,23 +130,11 @@ size_t http_parser_execute(http_parser *parser, const char *buffer, size_t len,
117
130
  assert(parser->field_len <= len && "field has length longer than whole buffer");
118
131
  assert(parser->field_start < len && "field starts after buffer end");
119
132
 
120
- if(parser->body_start) {
121
- /* final \r\n combo encountered so stop right here */
122
- %%write eof;
123
- parser->nread++;
124
- }
125
-
126
133
  return(parser->nread);
127
134
  }
128
135
 
129
136
  int http_parser_finish(http_parser *parser)
130
137
  {
131
- int cs = parser->cs;
132
-
133
- %%write eof;
134
-
135
- parser->cs = cs;
136
-
137
138
  if (http_parser_has_error(parser) ) {
138
139
  return -1;
139
140
  } else if (http_parser_is_finished(parser) ) {
@@ -148,5 +149,5 @@ int http_parser_has_error(http_parser *parser) {
148
149
  }
149
150
 
150
151
  int http_parser_is_finished(http_parser *parser) {
151
- return parser->cs == http_parser_first_final;
152
+ return parser->cs >= http_parser_first_final;
152
153
  }
@@ -41,7 +41,7 @@
41
41
  HTTP_Version = ( "HTTP/" http_number ) >mark %http_version ;
42
42
  Request_Line = ( Method " " Request_URI ("#" Fragment){0,1} " " HTTP_Version CRLF ) ;
43
43
 
44
- field_name = ( token -- ":" )+ >start_field %write_field;
44
+ field_name = ( token -- ":" )+ >start_field $snake_upcase_field %write_field;
45
45
 
46
46
  field_value = any* >start_value %write_value;
47
47
 
@@ -1,30 +1,3 @@
1
- /***** BEGIN LICENSE BLOCK *****
2
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
3
- *
4
- * The contents of this file are subject to the Common Public
5
- * License Version 1.0 (the "License"); you may not use this file
6
- * except in compliance with the License. You may obtain a copy of
7
- * the License at http://www.eclipse.org/legal/cpl-v10.html
8
- *
9
- * Software distributed under the License is distributed on an "AS
10
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
- * implied. See the License for the specific language governing
12
- * rights and limitations under the License.
13
- *
14
- * Copyright (C) 2007 Ola Bini <ola@ologix.com>
15
- *
16
- * Alternatively, the contents of this file may be used under the terms of
17
- * either of the GNU General Public License Version 2 or later (the "GPL"),
18
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
19
- * in which case the provisions of the GPL or the LGPL are applicable instead
20
- * of those above. If you wish to allow use of your version of this file only
21
- * under the terms of either the GPL or the LGPL, and not to allow others to
22
- * use your version of this file under the terms of the CPL, indicate your
23
- * decision by deleting the provisions above and replace them with the notice
24
- * and other provisions required by the GPL or the LGPL. If you do not delete
25
- * the provisions above, a recipient may use your version of this file under
26
- * the terms of any one of the CPL, the GPL or the LGPL.
27
- ***** END LICENSE BLOCK *****/
28
1
  package org.jruby.mongrel;
29
2
 
30
3
  import org.jruby.Ruby;
@@ -35,8 +8,10 @@ import org.jruby.RubyNumeric;
35
8
  import org.jruby.RubyObject;
36
9
  import org.jruby.RubyString;
37
10
 
38
- import org.jruby.runtime.CallbackFactory;
11
+ import org.jruby.anno.JRubyMethod;
12
+
39
13
  import org.jruby.runtime.ObjectAllocator;
14
+ import org.jruby.runtime.ThreadContext;
40
15
  import org.jruby.runtime.builtin.IRubyObject;
41
16
 
42
17
  import org.jruby.exceptions.RaiseException;
@@ -73,16 +48,8 @@ public class Http11 extends RubyObject {
73
48
  RubyModule mMongrel = runtime.defineModule("Mongrel");
74
49
  mMongrel.defineClassUnder("HttpParserError",runtime.getClass("IOError"),runtime.getClass("IOError").getAllocator());
75
50
 
76
- CallbackFactory cf = runtime.callbackFactory(Http11.class);
77
-
78
51
  RubyClass cHttpParser = mMongrel.defineClassUnder("HttpParser",runtime.getObject(),ALLOCATOR);
79
- cHttpParser.defineFastMethod("initialize",cf.getFastMethod("initialize"));
80
- cHttpParser.defineFastMethod("reset",cf.getFastMethod("reset"));
81
- cHttpParser.defineFastMethod("finish",cf.getFastMethod("finish"));
82
- cHttpParser.defineFastMethod("execute",cf.getFastMethod("execute", IRubyObject.class, IRubyObject.class, IRubyObject.class));
83
- cHttpParser.defineFastMethod("error?",cf.getFastMethod("has_error"));
84
- cHttpParser.defineFastMethod("finished?",cf.getFastMethod("is_finished"));
85
- cHttpParser.defineFastMethod("nread",cf.getFastMethod("nread"));
52
+ cHttpParser.defineAnnotatedMethods(Http11.class);
86
53
  }
87
54
 
88
55
  private Ruby runtime;
@@ -121,15 +88,15 @@ public class Http11 extends RubyObject {
121
88
  v = RubyString.newString(runtime, new ByteList(Http11.this.hp.parser.buffer,value,vlen));
122
89
  f = RubyString.newString(runtime, "HTTP_");
123
90
  ByteList b = new ByteList(Http11.this.hp.parser.buffer,field,flen);
124
- for(int i=0,j=b.realSize;i<j;i++) {
125
- if((b.bytes[i]&0xFF) == '-') {
126
- b.bytes[i] = (byte)'_';
91
+ for(int i = 0,j = b.length();i<j;i++) {
92
+ if((b.get(i) & 0xFF) == '-') {
93
+ b.set(i, (byte)'_');
127
94
  } else {
128
- b.bytes[i] = (byte)Character.toUpperCase((char)b.bytes[i]);
95
+ b.set(i, (byte)Character.toUpperCase((char)b.get(i)));
129
96
  }
130
97
  }
131
98
  f.cat(b);
132
- req.aset(f,v);
99
+ req.op_aset(req.getRuntime().getCurrentContext(), f,v);
133
100
  }
134
101
  };
135
102
 
@@ -137,7 +104,7 @@ public class Http11 extends RubyObject {
137
104
  public void call(Object data, int at, int length) {
138
105
  RubyHash req = (RubyHash)data;
139
106
  RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
140
- req.aset(runtime.newString("REQUEST_METHOD"),val);
107
+ req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("REQUEST_METHOD"),val);
141
108
  }
142
109
  };
143
110
 
@@ -146,7 +113,7 @@ public class Http11 extends RubyObject {
146
113
  RubyHash req = (RubyHash)data;
147
114
  validateMaxLength(length, MAX_REQUEST_URI_LENGTH, MAX_REQUEST_URI_LENGTH_ERR);
148
115
  RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
149
- req.aset(runtime.newString("REQUEST_URI"),val);
116
+ req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("REQUEST_URI"),val);
150
117
  }
151
118
  };
152
119
 
@@ -155,7 +122,7 @@ public class Http11 extends RubyObject {
155
122
  RubyHash req = (RubyHash)data;
156
123
  validateMaxLength(length, MAX_FRAGMENT_LENGTH, MAX_FRAGMENT_LENGTH_ERR);
157
124
  RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
158
- req.aset(runtime.newString("FRAGMENT"),val);
125
+ req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("FRAGMENT"),val);
159
126
  }
160
127
  };
161
128
 
@@ -164,7 +131,7 @@ public class Http11 extends RubyObject {
164
131
  RubyHash req = (RubyHash)data;
165
132
  validateMaxLength(length, MAX_REQUEST_PATH_LENGTH, MAX_REQUEST_PATH_LENGTH_ERR);
166
133
  RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
167
- req.aset(runtime.newString("REQUEST_PATH"),val);
134
+ req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("REQUEST_PATH"),val);
168
135
  }
169
136
  };
170
137
 
@@ -173,7 +140,7 @@ public class Http11 extends RubyObject {
173
140
  RubyHash req = (RubyHash)data;
174
141
  validateMaxLength(length, MAX_QUERY_STRING_LENGTH, MAX_QUERY_STRING_LENGTH_ERR);
175
142
  RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
176
- req.aset(runtime.newString("QUERY_STRING"),val);
143
+ req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("QUERY_STRING"),val);
177
144
  }
178
145
  };
179
146
 
@@ -181,64 +148,69 @@ public class Http11 extends RubyObject {
181
148
  public void call(Object data, int at, int length) {
182
149
  RubyHash req = (RubyHash)data;
183
150
  RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
184
- req.aset(runtime.newString("HTTP_VERSION"),val);
151
+ req.op_aset(req.getRuntime().getCurrentContext(), runtime.newString("HTTP_VERSION"),val);
185
152
  }
186
153
  };
187
154
 
188
155
  private Http11Parser.ElementCB header_done = new Http11Parser.ElementCB() {
189
156
  public void call(Object data, int at, int length) {
190
157
  RubyHash req = (RubyHash)data;
158
+ ThreadContext context = req.getRuntime().getCurrentContext();
191
159
  IRubyObject temp,ctype,clen;
192
160
 
193
- clen = req.aref(runtime.newString("HTTP_CONTENT_LENGTH"));
161
+ clen = req.op_aref(context, runtime.newString("HTTP_CONTENT_LENGTH"));
194
162
  if(!clen.isNil()) {
195
- req.aset(runtime.newString("CONTENT_LENGTH"),clen);
163
+ req.op_aset(context, runtime.newString("CONTENT_LENGTH"),clen);
196
164
  }
197
165
 
198
- ctype = req.aref(runtime.newString("HTTP_CONTENT_TYPE"));
166
+ ctype = req.op_aref(context, runtime.newString("HTTP_CONTENT_TYPE"));
199
167
  if(!ctype.isNil()) {
200
- req.aset(runtime.newString("CONTENT_TYPE"),ctype);
168
+ req.op_aset(context, runtime.newString("CONTENT_TYPE"),ctype);
201
169
  }
202
170
 
203
- req.aset(runtime.newString("GATEWAY_INTERFACE"),runtime.newString("CGI/1.2"));
204
- if(!(temp = req.aref(runtime.newString("HTTP_HOST"))).isNil()) {
171
+ req.op_aset(context, runtime.newString("GATEWAY_INTERFACE"),runtime.newString("CGI/1.2"));
172
+ if(!(temp = req.op_aref(context, runtime.newString("HTTP_HOST"))).isNil()) {
205
173
  String s = temp.toString();
206
174
  int colon = s.indexOf(':');
207
175
  if(colon != -1) {
208
- req.aset(runtime.newString("SERVER_NAME"),runtime.newString(s.substring(0,colon)));
209
- req.aset(runtime.newString("SERVER_PORT"),runtime.newString(s.substring(colon+1)));
176
+ req.op_aset(context, runtime.newString("SERVER_NAME"),runtime.newString(s.substring(0,colon)));
177
+ req.op_aset(context, runtime.newString("SERVER_PORT"),runtime.newString(s.substring(colon+1)));
210
178
  } else {
211
- req.aset(runtime.newString("SERVER_NAME"),temp);
212
- req.aset(runtime.newString("SERVER_PORT"),runtime.newString("80"));
179
+ req.op_aset(context, runtime.newString("SERVER_NAME"),temp);
180
+ req.op_aset(context, runtime.newString("SERVER_PORT"),runtime.newString("80"));
213
181
  }
214
182
  }
215
183
 
216
184
  req.setInstanceVariable("@http_body", RubyString.newString(runtime, new ByteList(hp.parser.buffer, at, length)));
217
- req.aset(runtime.newString("SERVER_PROTOCOL"),runtime.newString("HTTP/1.1"));
218
- req.aset(runtime.newString("SERVER_SOFTWARE"),runtime.newString("Mongrel 1.1.5"));
185
+ req.op_aset(context, runtime.newString("SERVER_PROTOCOL"),runtime.newString("HTTP/1.1"));
186
+ req.op_aset(context, runtime.newString("SERVER_SOFTWARE"),runtime.newString("Mongrel 1.2.0.pre2"));
219
187
  }
220
188
  };
221
189
 
190
+ @JRubyMethod
222
191
  public IRubyObject initialize() {
223
192
  this.hp.parser.init();
224
193
  return this;
225
194
  }
226
195
 
196
+ @JRubyMethod
227
197
  public IRubyObject reset() {
228
198
  this.hp.parser.init();
229
199
  return runtime.getNil();
230
200
  }
231
201
 
202
+ @JRubyMethod
232
203
  public IRubyObject finish() {
233
204
  this.hp.finish();
234
205
  return this.hp.is_finished() ? runtime.getTrue() : runtime.getFalse();
235
206
  }
236
207
 
208
+ @JRubyMethod
237
209
  public IRubyObject execute(IRubyObject req_hash, IRubyObject data, IRubyObject start) {
238
210
  int from = 0;
239
211
  from = RubyNumeric.fix2int(start);
240
212
  ByteList d = ((RubyString)data).getByteList();
241
- if(from >= d.realSize) {
213
+ if(from >= d.length()) {
242
214
  throw new RaiseException(runtime, eHttpParserError, "Requested start is after data buffer end.", true);
243
215
  } else {
244
216
  this.hp.parser.data = req_hash;
@@ -247,19 +219,22 @@ public class Http11 extends RubyObject {
247
219
  if(this.hp.has_error()) {
248
220
  throw new RaiseException(runtime, eHttpParserError, "Invalid HTTP format, parsing fails.", true);
249
221
  } else {
250
- return runtime.newFixnum((long)this.hp.parser.nread);
222
+ return runtime.newFixnum(this.hp.parser.nread);
251
223
  }
252
224
  }
253
225
  }
254
226
 
227
+ @JRubyMethod(name = "error?")
255
228
  public IRubyObject has_error() {
256
229
  return this.hp.has_error() ? runtime.getTrue() : runtime.getFalse();
257
230
  }
258
231
 
232
+ @JRubyMethod(name = "finished?")
259
233
  public IRubyObject is_finished() {
260
234
  return this.hp.is_finished() ? runtime.getTrue() : runtime.getFalse();
261
235
  }
262
236
 
237
+ @JRubyMethod
263
238
  public IRubyObject nread() {
264
239
  return runtime.newFixnum(this.hp.parser.nread);
265
240
  }
@@ -0,0 +1,486 @@
1
+
2
+ // line 1 "ext/http11/http11_parser.java.rl"
3
+ package org.jruby.mongrel;
4
+
5
+ import org.jruby.util.ByteList;
6
+
7
+ public class Http11Parser {
8
+
9
+ /** Machine **/
10
+
11
+
12
+ // line 65 "ext/http11/http11_parser.java.rl"
13
+
14
+
15
+ /** Data **/
16
+
17
+ // line 18 "ext/http11/org/jruby/mongrel/Http11Parser.java"
18
+ private static byte[] init__http_parser_actions_0()
19
+ {
20
+ return new byte [] {
21
+ 0, 1, 0, 1, 2, 1, 3, 1, 4, 1, 5, 1,
22
+ 6, 1, 7, 1, 8, 1, 9, 1, 11, 1, 12, 1,
23
+ 13, 2, 0, 8, 2, 1, 2, 2, 4, 5, 2, 10,
24
+ 7, 2, 12, 7, 3, 9, 10, 7
25
+ };
26
+ }
27
+
28
+ private static final byte _http_parser_actions[] = init__http_parser_actions_0();
29
+
30
+
31
+ private static short[] init__http_parser_key_offsets_0()
32
+ {
33
+ return new short [] {
34
+ 0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36,
35
+ 39, 41, 44, 45, 61, 62, 78, 80, 81, 90, 99, 105,
36
+ 111, 121, 130, 136, 142, 153, 159, 165, 175, 181, 187, 196,
37
+ 205, 211, 217, 226, 235, 244, 253, 262, 271, 280, 289, 298,
38
+ 307, 316, 325, 334, 343, 352, 361, 370, 379, 380
39
+ };
40
+ }
41
+
42
+ private static final short _http_parser_key_offsets[] = init__http_parser_key_offsets_0();
43
+
44
+
45
+ private static char[] init__http_parser_trans_keys_0()
46
+ {
47
+ return new char [] {
48
+ 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
49
+ 46, 48, 57, 65, 90, 42, 43, 47, 58, 45, 57, 65,
50
+ 90, 97, 122, 32, 35, 72, 84, 84, 80, 47, 48, 57,
51
+ 46, 48, 57, 48, 57, 13, 48, 57, 10, 13, 33, 124,
52
+ 126, 35, 39, 42, 43, 45, 46, 48, 57, 65, 90, 94,
53
+ 122, 10, 33, 58, 124, 126, 35, 39, 42, 43, 45, 46,
54
+ 48, 57, 65, 90, 94, 122, 13, 32, 13, 32, 37, 60,
55
+ 62, 127, 0, 31, 34, 35, 32, 37, 60, 62, 127, 0,
56
+ 31, 34, 35, 48, 57, 65, 70, 97, 102, 48, 57, 65,
57
+ 70, 97, 102, 43, 58, 45, 46, 48, 57, 65, 90, 97,
58
+ 122, 32, 34, 35, 37, 60, 62, 127, 0, 31, 48, 57,
59
+ 65, 70, 97, 102, 48, 57, 65, 70, 97, 102, 32, 34,
60
+ 35, 37, 59, 60, 62, 63, 127, 0, 31, 48, 57, 65,
61
+ 70, 97, 102, 48, 57, 65, 70, 97, 102, 32, 34, 35,
62
+ 37, 60, 62, 63, 127, 0, 31, 48, 57, 65, 70, 97,
63
+ 102, 48, 57, 65, 70, 97, 102, 32, 34, 35, 37, 60,
64
+ 62, 127, 0, 31, 32, 34, 35, 37, 60, 62, 127, 0,
65
+ 31, 48, 57, 65, 70, 97, 102, 48, 57, 65, 70, 97,
66
+ 102, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36,
67
+ 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46,
68
+ 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65,
69
+ 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36,
70
+ 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46,
71
+ 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65,
72
+ 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36,
73
+ 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46,
74
+ 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65,
75
+ 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36,
76
+ 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46,
77
+ 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65,
78
+ 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36,
79
+ 95, 45, 46, 48, 57, 65, 90, 32, 0
80
+ };
81
+ }
82
+
83
+ private static final char _http_parser_trans_keys[] = init__http_parser_trans_keys_0();
84
+
85
+
86
+ private static byte[] init__http_parser_single_lengths_0()
87
+ {
88
+ return new byte [] {
89
+ 0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1,
90
+ 0, 1, 1, 4, 1, 4, 2, 1, 5, 5, 0, 0,
91
+ 2, 7, 0, 0, 9, 0, 0, 8, 0, 0, 7, 7,
92
+ 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
93
+ 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
94
+ };
95
+ }
96
+
97
+ private static final byte _http_parser_single_lengths[] = init__http_parser_single_lengths_0();
98
+
99
+
100
+ private static byte[] init__http_parser_range_lengths_0()
101
+ {
102
+ return new byte [] {
103
+ 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1,
104
+ 1, 1, 0, 6, 0, 6, 0, 0, 2, 2, 3, 3,
105
+ 4, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 1,
106
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
107
+ 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
108
+ };
109
+ }
110
+
111
+ private static final byte _http_parser_range_lengths[] = init__http_parser_range_lengths_0();
112
+
113
+
114
+ private static short[] init__http_parser_index_offsets_0()
115
+ {
116
+ return new short [] {
117
+ 0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36,
118
+ 39, 41, 44, 46, 57, 59, 70, 73, 75, 83, 91, 95,
119
+ 99, 106, 115, 119, 123, 134, 138, 142, 152, 156, 160, 169,
120
+ 178, 182, 186, 193, 200, 207, 214, 221, 228, 235, 242, 249,
121
+ 256, 263, 270, 277, 284, 291, 298, 305, 312, 314
122
+ };
123
+ }
124
+
125
+ private static final short _http_parser_index_offsets[] = init__http_parser_index_offsets_0();
126
+
127
+
128
+ private static byte[] init__http_parser_indicies_0()
129
+ {
130
+ return new byte [] {
131
+ 0, 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3,
132
+ 1, 4, 5, 6, 7, 5, 5, 5, 1, 8, 9, 1,
133
+ 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1,
134
+ 16, 15, 1, 17, 1, 18, 17, 1, 19, 1, 20, 21,
135
+ 21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23,
136
+ 24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 26, 27,
137
+ 25, 29, 28, 30, 32, 1, 1, 1, 1, 1, 31, 33,
138
+ 35, 1, 1, 1, 1, 1, 34, 36, 36, 36, 1, 34,
139
+ 34, 34, 1, 37, 38, 37, 37, 37, 37, 1, 8, 1,
140
+ 9, 39, 1, 1, 1, 1, 38, 40, 40, 40, 1, 38,
141
+ 38, 38, 1, 41, 1, 43, 44, 45, 1, 1, 46, 1,
142
+ 1, 42, 47, 47, 47, 1, 42, 42, 42, 1, 8, 1,
143
+ 9, 49, 1, 1, 50, 1, 1, 48, 51, 51, 51, 1,
144
+ 48, 48, 48, 1, 52, 1, 54, 55, 1, 1, 1, 1,
145
+ 53, 56, 1, 58, 59, 1, 1, 1, 1, 57, 60, 60,
146
+ 60, 1, 57, 57, 57, 1, 2, 61, 61, 61, 61, 61,
147
+ 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63, 63,
148
+ 63, 63, 1, 2, 64, 64, 64, 64, 64, 1, 2, 65,
149
+ 65, 65, 65, 65, 1, 2, 66, 66, 66, 66, 66, 1,
150
+ 2, 67, 67, 67, 67, 67, 1, 2, 68, 68, 68, 68,
151
+ 68, 1, 2, 69, 69, 69, 69, 69, 1, 2, 70, 70,
152
+ 70, 70, 70, 1, 2, 71, 71, 71, 71, 71, 1, 2,
153
+ 72, 72, 72, 72, 72, 1, 2, 73, 73, 73, 73, 73,
154
+ 1, 2, 74, 74, 74, 74, 74, 1, 2, 75, 75, 75,
155
+ 75, 75, 1, 2, 76, 76, 76, 76, 76, 1, 2, 77,
156
+ 77, 77, 77, 77, 1, 2, 78, 78, 78, 78, 78, 1,
157
+ 2, 1, 1, 0
158
+ };
159
+ }
160
+
161
+ private static final byte _http_parser_indicies[] = init__http_parser_indicies_0();
162
+
163
+
164
+ private static byte[] init__http_parser_trans_targs_0()
165
+ {
166
+ return new byte [] {
167
+ 2, 0, 3, 38, 4, 24, 28, 25, 5, 20, 6, 7,
168
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 57, 17,
169
+ 18, 19, 14, 18, 19, 14, 5, 21, 22, 5, 21, 22,
170
+ 23, 24, 25, 26, 27, 5, 28, 20, 29, 31, 34, 30,
171
+ 31, 32, 34, 33, 5, 35, 20, 36, 5, 35, 20, 36,
172
+ 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
173
+ 50, 51, 52, 53, 54, 55, 56
174
+ };
175
+ }
176
+
177
+ private static final byte _http_parser_trans_targs[] = init__http_parser_trans_targs_0();
178
+
179
+
180
+ private static byte[] init__http_parser_trans_actions_0()
181
+ {
182
+ return new byte [] {
183
+ 1, 0, 11, 0, 1, 1, 1, 1, 13, 13, 1, 0,
184
+ 0, 0, 0, 0, 0, 0, 19, 0, 0, 28, 23, 3,
185
+ 5, 7, 31, 7, 0, 9, 25, 1, 1, 15, 0, 0,
186
+ 0, 0, 0, 0, 0, 37, 0, 37, 0, 21, 21, 0,
187
+ 0, 0, 0, 0, 40, 17, 40, 17, 34, 0, 34, 0,
188
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
189
+ 0, 0, 0, 0, 0, 0, 0
190
+ };
191
+ }
192
+
193
+ private static final byte _http_parser_trans_actions[] = init__http_parser_trans_actions_0();
194
+
195
+
196
+ static final int http_parser_start = 1;
197
+ static final int http_parser_first_final = 57;
198
+ static final int http_parser_error = 0;
199
+
200
+ static final int http_parser_en_main = 1;
201
+
202
+
203
+ // line 69 "ext/http11/http11_parser.java.rl"
204
+
205
+ public static interface ElementCB {
206
+ public void call(Object data, int at, int length);
207
+ }
208
+
209
+ public static interface FieldCB {
210
+ public void call(Object data, int field, int flen, int value, int vlen);
211
+ }
212
+
213
+ public static class HttpParser {
214
+ int cs;
215
+ int body_start;
216
+ int content_len;
217
+ int nread;
218
+ int mark;
219
+ int field_start;
220
+ int field_len;
221
+ int query_start;
222
+
223
+ Object data;
224
+ ByteList buffer;
225
+
226
+ public FieldCB http_field;
227
+ public ElementCB request_method;
228
+ public ElementCB request_uri;
229
+ public ElementCB fragment;
230
+ public ElementCB request_path;
231
+ public ElementCB query_string;
232
+ public ElementCB http_version;
233
+ public ElementCB header_done;
234
+
235
+ public void init() {
236
+ cs = 0;
237
+
238
+
239
+ // line 240 "ext/http11/org/jruby/mongrel/Http11Parser.java"
240
+ {
241
+ cs = http_parser_start;
242
+ }
243
+
244
+ // line 104 "ext/http11/http11_parser.java.rl"
245
+
246
+ body_start = 0;
247
+ content_len = 0;
248
+ mark = 0;
249
+ nread = 0;
250
+ field_len = 0;
251
+ field_start = 0;
252
+ }
253
+ }
254
+
255
+ public final HttpParser parser = new HttpParser();
256
+
257
+ public int execute(ByteList buffer, int off) {
258
+ int p, pe;
259
+ int cs = parser.cs;
260
+ int len = buffer.length();
261
+ assert off<=len : "offset past end of buffer";
262
+
263
+ p = off;
264
+ pe = len;
265
+ byte[] data = buffer.unsafeBytes();
266
+ parser.buffer = buffer;
267
+
268
+
269
+ // line 270 "ext/http11/org/jruby/mongrel/Http11Parser.java"
270
+ {
271
+ int _klen;
272
+ int _trans = 0;
273
+ int _acts;
274
+ int _nacts;
275
+ int _keys;
276
+ int _goto_targ = 0;
277
+
278
+ _goto: while (true) {
279
+ switch ( _goto_targ ) {
280
+ case 0:
281
+ if ( p == pe ) {
282
+ _goto_targ = 4;
283
+ continue _goto;
284
+ }
285
+ if ( cs == 0 ) {
286
+ _goto_targ = 5;
287
+ continue _goto;
288
+ }
289
+ case 1:
290
+ _match: do {
291
+ _keys = _http_parser_key_offsets[cs];
292
+ _trans = _http_parser_index_offsets[cs];
293
+ _klen = _http_parser_single_lengths[cs];
294
+ if ( _klen > 0 ) {
295
+ int _lower = _keys;
296
+ int _mid;
297
+ int _upper = _keys + _klen - 1;
298
+ while (true) {
299
+ if ( _upper < _lower )
300
+ break;
301
+
302
+ _mid = _lower + ((_upper-_lower) >> 1);
303
+ if ( data[p] < _http_parser_trans_keys[_mid] )
304
+ _upper = _mid - 1;
305
+ else if ( data[p] > _http_parser_trans_keys[_mid] )
306
+ _lower = _mid + 1;
307
+ else {
308
+ _trans += (_mid - _keys);
309
+ break _match;
310
+ }
311
+ }
312
+ _keys += _klen;
313
+ _trans += _klen;
314
+ }
315
+
316
+ _klen = _http_parser_range_lengths[cs];
317
+ if ( _klen > 0 ) {
318
+ int _lower = _keys;
319
+ int _mid;
320
+ int _upper = _keys + (_klen<<1) - 2;
321
+ while (true) {
322
+ if ( _upper < _lower )
323
+ break;
324
+
325
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
326
+ if ( data[p] < _http_parser_trans_keys[_mid] )
327
+ _upper = _mid - 2;
328
+ else if ( data[p] > _http_parser_trans_keys[_mid+1] )
329
+ _lower = _mid + 2;
330
+ else {
331
+ _trans += ((_mid - _keys)>>1);
332
+ break _match;
333
+ }
334
+ }
335
+ _trans += _klen;
336
+ }
337
+ } while (false);
338
+
339
+ _trans = _http_parser_indicies[_trans];
340
+ cs = _http_parser_trans_targs[_trans];
341
+
342
+ if ( _http_parser_trans_actions[_trans] != 0 ) {
343
+ _acts = _http_parser_trans_actions[_trans];
344
+ _nacts = (int) _http_parser_actions[_acts++];
345
+ while ( _nacts-- > 0 )
346
+ {
347
+ switch ( _http_parser_actions[_acts++] )
348
+ {
349
+ case 0:
350
+ // line 13 "ext/http11/http11_parser.java.rl"
351
+ {parser.mark = p; }
352
+ break;
353
+ case 1:
354
+ // line 15 "ext/http11/http11_parser.java.rl"
355
+ { parser.field_start = p; }
356
+ break;
357
+ case 2:
358
+ // line 16 "ext/http11/http11_parser.java.rl"
359
+ { /* FIXME stub */ }
360
+ break;
361
+ case 3:
362
+ // line 17 "ext/http11/http11_parser.java.rl"
363
+ {
364
+ parser.field_len = p-parser.field_start;
365
+ }
366
+ break;
367
+ case 4:
368
+ // line 21 "ext/http11/http11_parser.java.rl"
369
+ { parser.mark = p; }
370
+ break;
371
+ case 5:
372
+ // line 22 "ext/http11/http11_parser.java.rl"
373
+ {
374
+ if(parser.http_field != null) {
375
+ parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, p-parser.mark);
376
+ }
377
+ }
378
+ break;
379
+ case 6:
380
+ // line 27 "ext/http11/http11_parser.java.rl"
381
+ {
382
+ if(parser.request_method != null)
383
+ parser.request_method.call(parser.data, parser.mark, p-parser.mark);
384
+ }
385
+ break;
386
+ case 7:
387
+ // line 31 "ext/http11/http11_parser.java.rl"
388
+ {
389
+ if(parser.request_uri != null)
390
+ parser.request_uri.call(parser.data, parser.mark, p-parser.mark);
391
+ }
392
+ break;
393
+ case 8:
394
+ // line 35 "ext/http11/http11_parser.java.rl"
395
+ {
396
+ if(parser.fragment != null)
397
+ parser.fragment.call(parser.data, parser.mark, p-parser.mark);
398
+ }
399
+ break;
400
+ case 9:
401
+ // line 40 "ext/http11/http11_parser.java.rl"
402
+ {parser.query_start = p; }
403
+ break;
404
+ case 10:
405
+ // line 41 "ext/http11/http11_parser.java.rl"
406
+ {
407
+ if(parser.query_string != null)
408
+ parser.query_string.call(parser.data, parser.query_start, p-parser.query_start);
409
+ }
410
+ break;
411
+ case 11:
412
+ // line 46 "ext/http11/http11_parser.java.rl"
413
+ {
414
+ if(parser.http_version != null)
415
+ parser.http_version.call(parser.data, parser.mark, p-parser.mark);
416
+ }
417
+ break;
418
+ case 12:
419
+ // line 51 "ext/http11/http11_parser.java.rl"
420
+ {
421
+ if(parser.request_path != null)
422
+ parser.request_path.call(parser.data, parser.mark, p-parser.mark);
423
+ }
424
+ break;
425
+ case 13:
426
+ // line 56 "ext/http11/http11_parser.java.rl"
427
+ {
428
+ parser.body_start = p + 1;
429
+ if(parser.header_done != null)
430
+ parser.header_done.call(parser.data, p + 1, pe - p - 1);
431
+ { p += 1; _goto_targ = 5; if (true) continue _goto;}
432
+ }
433
+ break;
434
+ // line 435 "ext/http11/org/jruby/mongrel/Http11Parser.java"
435
+ }
436
+ }
437
+ }
438
+
439
+ case 2:
440
+ if ( cs == 0 ) {
441
+ _goto_targ = 5;
442
+ continue _goto;
443
+ }
444
+ if ( ++p != pe ) {
445
+ _goto_targ = 1;
446
+ continue _goto;
447
+ }
448
+ case 4:
449
+ case 5:
450
+ }
451
+ break; }
452
+ }
453
+
454
+ // line 128 "ext/http11/http11_parser.java.rl"
455
+
456
+ parser.cs = cs;
457
+ parser.nread += (p - off);
458
+
459
+ assert p <= pe : "buffer overflow after parsing execute";
460
+ assert parser.nread <= len : "nread longer than length";
461
+ assert parser.body_start <= len : "body starts after buffer end";
462
+ assert parser.mark < len : "mark is after buffer end";
463
+ assert parser.field_len <= len : "field has length longer than whole buffer";
464
+ assert parser.field_start < len : "field starts after buffer end";
465
+
466
+ return parser.nread;
467
+ }
468
+
469
+ public int finish() {
470
+ if(has_error()) {
471
+ return -1;
472
+ } else if(is_finished()) {
473
+ return 1;
474
+ } else {
475
+ return 0;
476
+ }
477
+ }
478
+
479
+ public boolean has_error() {
480
+ return parser.cs == http_parser_error;
481
+ }
482
+
483
+ public boolean is_finished() {
484
+ return parser.cs == http_parser_first_final;
485
+ }
486
+ }