puma 0.8.2-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

Files changed (63) hide show
  1. data/.gemtest +0 -0
  2. data/COPYING +55 -0
  3. data/Gemfile +6 -0
  4. data/History.txt +69 -0
  5. data/LICENSE +26 -0
  6. data/Manifest.txt +60 -0
  7. data/README.md +60 -0
  8. data/Rakefile +12 -0
  9. data/TODO +5 -0
  10. data/bin/puma +15 -0
  11. data/examples/builder.rb +29 -0
  12. data/examples/camping/README +3 -0
  13. data/examples/camping/blog.rb +294 -0
  14. data/examples/camping/tepee.rb +149 -0
  15. data/examples/httpd.conf +474 -0
  16. data/examples/mime.yaml +3 -0
  17. data/examples/mongrel.conf +9 -0
  18. data/examples/monitrc +57 -0
  19. data/examples/random_thrash.rb +19 -0
  20. data/examples/simpletest.rb +52 -0
  21. data/examples/webrick_compare.rb +20 -0
  22. data/ext/puma_http11/PumaHttp11Service.java +13 -0
  23. data/ext/puma_http11/ext_help.h +15 -0
  24. data/ext/puma_http11/extconf.rb +5 -0
  25. data/ext/puma_http11/http11_parser.c +1225 -0
  26. data/ext/puma_http11/http11_parser.h +63 -0
  27. data/ext/puma_http11/http11_parser.java.rl +161 -0
  28. data/ext/puma_http11/http11_parser.rl +146 -0
  29. data/ext/puma_http11/http11_parser_common.rl +54 -0
  30. data/ext/puma_http11/org/jruby/puma/Http11.java +225 -0
  31. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +488 -0
  32. data/ext/puma_http11/puma_http11.c +482 -0
  33. data/lib/puma.rb +18 -0
  34. data/lib/puma/cli.rb +164 -0
  35. data/lib/puma/const.rb +132 -0
  36. data/lib/puma/events.rb +36 -0
  37. data/lib/puma/gems.rb +20 -0
  38. data/lib/puma/mime_types.yml +616 -0
  39. data/lib/puma/rack_patch.rb +22 -0
  40. data/lib/puma/server.rb +429 -0
  41. data/lib/puma/thread_pool.rb +95 -0
  42. data/lib/puma/utils.rb +44 -0
  43. data/lib/puma_http11.jar +0 -0
  44. data/lib/rack/handler/puma.rb +48 -0
  45. data/puma.gemspec +40 -0
  46. data/tasks/gem.rake +24 -0
  47. data/tasks/java.rake +12 -0
  48. data/tasks/native.rake +36 -0
  49. data/tasks/ragel.rake +24 -0
  50. data/test/lobster.ru +4 -0
  51. data/test/mime.yaml +3 -0
  52. data/test/test_cli.rb +19 -0
  53. data/test/test_http10.rb +27 -0
  54. data/test/test_http11.rb +151 -0
  55. data/test/test_persistent.rb +205 -0
  56. data/test/test_rack_handler.rb +10 -0
  57. data/test/test_rack_server.rb +122 -0
  58. data/test/test_thread_pool.rb +102 -0
  59. data/test/test_unix_socket.rb +37 -0
  60. data/test/test_ws.rb +97 -0
  61. data/test/testhelp.rb +41 -0
  62. data/tools/trickletest.rb +45 -0
  63. metadata +163 -0
@@ -0,0 +1,488 @@
1
+
2
+ // line 1 "ext/puma_http11/http11_parser.java.rl"
3
+ package org.jruby.puma;
4
+
5
+ import org.jruby.util.ByteList;
6
+
7
+ public class Http11Parser {
8
+
9
+ /** Machine **/
10
+
11
+
12
+ // line 65 "ext/puma_http11/http11_parser.java.rl"
13
+
14
+
15
+ /** Data **/
16
+
17
+ // line 18 "ext/puma_http11/org/jruby/puma/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/puma_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/puma_http11/org/jruby/puma/Http11Parser.java"
240
+ {
241
+ cs = http_parser_start;
242
+ }
243
+
244
+ // line 104 "ext/puma_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
+ // get a copy of the bytes, since it may not start at 0
266
+ // FIXME: figure out how to just use the bytes in-place
267
+ byte[] data = buffer.bytes();
268
+ parser.buffer = buffer;
269
+
270
+
271
+ // line 272 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
272
+ {
273
+ int _klen;
274
+ int _trans = 0;
275
+ int _acts;
276
+ int _nacts;
277
+ int _keys;
278
+ int _goto_targ = 0;
279
+
280
+ _goto: while (true) {
281
+ switch ( _goto_targ ) {
282
+ case 0:
283
+ if ( p == pe ) {
284
+ _goto_targ = 4;
285
+ continue _goto;
286
+ }
287
+ if ( cs == 0 ) {
288
+ _goto_targ = 5;
289
+ continue _goto;
290
+ }
291
+ case 1:
292
+ _match: do {
293
+ _keys = _http_parser_key_offsets[cs];
294
+ _trans = _http_parser_index_offsets[cs];
295
+ _klen = _http_parser_single_lengths[cs];
296
+ if ( _klen > 0 ) {
297
+ int _lower = _keys;
298
+ int _mid;
299
+ int _upper = _keys + _klen - 1;
300
+ while (true) {
301
+ if ( _upper < _lower )
302
+ break;
303
+
304
+ _mid = _lower + ((_upper-_lower) >> 1);
305
+ if ( data[p] < _http_parser_trans_keys[_mid] )
306
+ _upper = _mid - 1;
307
+ else if ( data[p] > _http_parser_trans_keys[_mid] )
308
+ _lower = _mid + 1;
309
+ else {
310
+ _trans += (_mid - _keys);
311
+ break _match;
312
+ }
313
+ }
314
+ _keys += _klen;
315
+ _trans += _klen;
316
+ }
317
+
318
+ _klen = _http_parser_range_lengths[cs];
319
+ if ( _klen > 0 ) {
320
+ int _lower = _keys;
321
+ int _mid;
322
+ int _upper = _keys + (_klen<<1) - 2;
323
+ while (true) {
324
+ if ( _upper < _lower )
325
+ break;
326
+
327
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
328
+ if ( data[p] < _http_parser_trans_keys[_mid] )
329
+ _upper = _mid - 2;
330
+ else if ( data[p] > _http_parser_trans_keys[_mid+1] )
331
+ _lower = _mid + 2;
332
+ else {
333
+ _trans += ((_mid - _keys)>>1);
334
+ break _match;
335
+ }
336
+ }
337
+ _trans += _klen;
338
+ }
339
+ } while (false);
340
+
341
+ _trans = _http_parser_indicies[_trans];
342
+ cs = _http_parser_trans_targs[_trans];
343
+
344
+ if ( _http_parser_trans_actions[_trans] != 0 ) {
345
+ _acts = _http_parser_trans_actions[_trans];
346
+ _nacts = (int) _http_parser_actions[_acts++];
347
+ while ( _nacts-- > 0 )
348
+ {
349
+ switch ( _http_parser_actions[_acts++] )
350
+ {
351
+ case 0:
352
+ // line 13 "ext/puma_http11/http11_parser.java.rl"
353
+ {parser.mark = p; }
354
+ break;
355
+ case 1:
356
+ // line 15 "ext/puma_http11/http11_parser.java.rl"
357
+ { parser.field_start = p; }
358
+ break;
359
+ case 2:
360
+ // line 16 "ext/puma_http11/http11_parser.java.rl"
361
+ { /* FIXME stub */ }
362
+ break;
363
+ case 3:
364
+ // line 17 "ext/puma_http11/http11_parser.java.rl"
365
+ {
366
+ parser.field_len = p-parser.field_start;
367
+ }
368
+ break;
369
+ case 4:
370
+ // line 21 "ext/puma_http11/http11_parser.java.rl"
371
+ { parser.mark = p; }
372
+ break;
373
+ case 5:
374
+ // line 22 "ext/puma_http11/http11_parser.java.rl"
375
+ {
376
+ if(parser.http_field != null) {
377
+ parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, p-parser.mark);
378
+ }
379
+ }
380
+ break;
381
+ case 6:
382
+ // line 27 "ext/puma_http11/http11_parser.java.rl"
383
+ {
384
+ if(parser.request_method != null)
385
+ parser.request_method.call(parser.data, parser.mark, p-parser.mark);
386
+ }
387
+ break;
388
+ case 7:
389
+ // line 31 "ext/puma_http11/http11_parser.java.rl"
390
+ {
391
+ if(parser.request_uri != null)
392
+ parser.request_uri.call(parser.data, parser.mark, p-parser.mark);
393
+ }
394
+ break;
395
+ case 8:
396
+ // line 35 "ext/puma_http11/http11_parser.java.rl"
397
+ {
398
+ if(parser.fragment != null)
399
+ parser.fragment.call(parser.data, parser.mark, p-parser.mark);
400
+ }
401
+ break;
402
+ case 9:
403
+ // line 40 "ext/puma_http11/http11_parser.java.rl"
404
+ {parser.query_start = p; }
405
+ break;
406
+ case 10:
407
+ // line 41 "ext/puma_http11/http11_parser.java.rl"
408
+ {
409
+ if(parser.query_string != null)
410
+ parser.query_string.call(parser.data, parser.query_start, p-parser.query_start);
411
+ }
412
+ break;
413
+ case 11:
414
+ // line 46 "ext/puma_http11/http11_parser.java.rl"
415
+ {
416
+ if(parser.http_version != null)
417
+ parser.http_version.call(parser.data, parser.mark, p-parser.mark);
418
+ }
419
+ break;
420
+ case 12:
421
+ // line 51 "ext/puma_http11/http11_parser.java.rl"
422
+ {
423
+ if(parser.request_path != null)
424
+ parser.request_path.call(parser.data, parser.mark, p-parser.mark);
425
+ }
426
+ break;
427
+ case 13:
428
+ // line 56 "ext/puma_http11/http11_parser.java.rl"
429
+ {
430
+ parser.body_start = p + 1;
431
+ if(parser.header_done != null)
432
+ parser.header_done.call(parser.data, p + 1, pe - p - 1);
433
+ { p += 1; _goto_targ = 5; if (true) continue _goto;}
434
+ }
435
+ break;
436
+ // line 437 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
437
+ }
438
+ }
439
+ }
440
+
441
+ case 2:
442
+ if ( cs == 0 ) {
443
+ _goto_targ = 5;
444
+ continue _goto;
445
+ }
446
+ if ( ++p != pe ) {
447
+ _goto_targ = 1;
448
+ continue _goto;
449
+ }
450
+ case 4:
451
+ case 5:
452
+ }
453
+ break; }
454
+ }
455
+
456
+ // line 130 "ext/puma_http11/http11_parser.java.rl"
457
+
458
+ parser.cs = cs;
459
+ parser.nread += (p - off);
460
+
461
+ assert p <= pe : "buffer overflow after parsing execute";
462
+ assert parser.nread <= len : "nread longer than length";
463
+ assert parser.body_start <= len : "body starts after buffer end";
464
+ assert parser.mark < len : "mark is after buffer end";
465
+ assert parser.field_len <= len : "field has length longer than whole buffer";
466
+ assert parser.field_start < len : "field starts after buffer end";
467
+
468
+ return parser.nread;
469
+ }
470
+
471
+ public int finish() {
472
+ if(has_error()) {
473
+ return -1;
474
+ } else if(is_finished()) {
475
+ return 1;
476
+ } else {
477
+ return 0;
478
+ }
479
+ }
480
+
481
+ public boolean has_error() {
482
+ return parser.cs == http_parser_error;
483
+ }
484
+
485
+ public boolean is_finished() {
486
+ return parser.cs == http_parser_first_final;
487
+ }
488
+ }