mongrel 1.2.0.pre2-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/COPYING +55 -0
  2. data/History.txt +68 -0
  3. data/LICENSE +55 -0
  4. data/Manifest.txt +69 -0
  5. data/README.txt +80 -0
  6. data/Rakefile +8 -0
  7. data/TODO +5 -0
  8. data/bin/mongrel_rails +284 -0
  9. data/examples/builder.rb +29 -0
  10. data/examples/camping/README +3 -0
  11. data/examples/camping/blog.rb +294 -0
  12. data/examples/camping/tepee.rb +149 -0
  13. data/examples/httpd.conf +474 -0
  14. data/examples/mime.yaml +3 -0
  15. data/examples/mongrel.conf +9 -0
  16. data/examples/monitrc +57 -0
  17. data/examples/random_thrash.rb +19 -0
  18. data/examples/simpletest.rb +52 -0
  19. data/examples/webrick_compare.rb +20 -0
  20. data/ext/http11/Http11Service.java +13 -0
  21. data/ext/http11/ext_help.h +15 -0
  22. data/ext/http11/extconf.rb +6 -0
  23. data/ext/http11/http11.c +534 -0
  24. data/ext/http11/http11_parser.c +1243 -0
  25. data/ext/http11/http11_parser.h +49 -0
  26. data/ext/http11/http11_parser.java.rl +159 -0
  27. data/ext/http11/http11_parser.rl +153 -0
  28. data/ext/http11/http11_parser_common.rl +54 -0
  29. data/ext/http11/org/jruby/mongrel/Http11.java +241 -0
  30. data/ext/http11/org/jruby/mongrel/Http11Parser.java +486 -0
  31. data/lib/1.8/http11.so +0 -0
  32. data/lib/1.9/http11.so +0 -0
  33. data/lib/mongrel.rb +366 -0
  34. data/lib/mongrel/camping.rb +107 -0
  35. data/lib/mongrel/cgi.rb +181 -0
  36. data/lib/mongrel/command.rb +220 -0
  37. data/lib/mongrel/configurator.rb +388 -0
  38. data/lib/mongrel/const.rb +110 -0
  39. data/lib/mongrel/debug.rb +203 -0
  40. data/lib/mongrel/gems.rb +22 -0
  41. data/lib/mongrel/handlers.rb +468 -0
  42. data/lib/mongrel/header_out.rb +28 -0
  43. data/lib/mongrel/http_request.rb +155 -0
  44. data/lib/mongrel/http_response.rb +166 -0
  45. data/lib/mongrel/init.rb +10 -0
  46. data/lib/mongrel/mime_types.yml +616 -0
  47. data/lib/mongrel/rails.rb +185 -0
  48. data/lib/mongrel/stats.rb +89 -0
  49. data/lib/mongrel/tcphack.rb +18 -0
  50. data/lib/mongrel/uri_classifier.rb +76 -0
  51. data/setup.rb +1585 -0
  52. data/tasks/gem.rake +28 -0
  53. data/tasks/native.rake +24 -0
  54. data/tasks/ragel.rake +20 -0
  55. data/test/mime.yaml +3 -0
  56. data/test/mongrel.conf +1 -0
  57. data/test/test_cgi_wrapper.rb +26 -0
  58. data/test/test_command.rb +86 -0
  59. data/test/test_conditional.rb +107 -0
  60. data/test/test_configurator.rb +87 -0
  61. data/test/test_debug.rb +25 -0
  62. data/test/test_handlers.rb +135 -0
  63. data/test/test_http11.rb +156 -0
  64. data/test/test_redirect_handler.rb +44 -0
  65. data/test/test_request_progress.rb +99 -0
  66. data/test/test_response.rb +127 -0
  67. data/test/test_stats.rb +35 -0
  68. data/test/test_uriclassifier.rb +261 -0
  69. data/test/test_ws.rb +117 -0
  70. data/test/testhelp.rb +71 -0
  71. data/tools/trickletest.rb +45 -0
  72. metadata +197 -0
@@ -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
+ }