rev 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,9 +1,19 @@
1
+ 0.2.2:
2
+
3
+ * Correct a pointer arithmetic error in the buffering code that could result
4
+ in data corruption.
5
+
6
+ * Upgrade to libev 3.41
7
+
8
+ * Relax HTTP/1.1 reponse parser to allow the "reason" portion of the response
9
+ header to be omitted
10
+
1
11
  0.2.1:
2
12
 
3
13
  * Upgrade to libev 3.31
4
14
 
5
15
  * Rev::Loop#run_once and Rev::Loop#run_nonblock now return the number of events
6
- received when they were running.
16
+ received when they were running
7
17
 
8
18
  * Remove inheritence relationship between Rev::IO and Rev::IOWatcher
9
19
 
data/README CHANGED
@@ -11,8 +11,16 @@ applications.
11
11
 
12
12
  You can include Rev in your programs with:
13
13
 
14
- require 'rubygems'
15
- require 'rev'
14
+ require 'rubygems'
15
+ require 'rev'
16
+
17
+ For more information, consult the RubyForge page:
18
+
19
+ http://rev.rubyforge.org
20
+
21
+ Questions? Sign up for the mailing list at:
22
+
23
+ http://rubyforge.org/mailman/listinfo/rev-talk
16
24
 
17
25
  == Anatomy
18
26
 
@@ -24,18 +24,157 @@
24
24
  /** Data **/
25
25
 
26
26
  #line 27 "http11_parser.c"
27
- static const int httpclient_parser_start = 1;
28
- static const int httpclient_parser_first_final = 37;
29
- static const int httpclient_parser_error = 0;
27
+ static const char _httpclient_parser_actions[] = {
28
+ 0, 1, 0, 1, 1, 1, 2, 1,
29
+ 3, 1, 4, 1, 5, 1, 7, 1,
30
+ 8, 1, 10, 2, 2, 3, 2, 6,
31
+ 0, 2, 6, 5, 2, 9, 10, 2,
32
+ 10, 9, 3, 2, 3, 4
33
+ };
30
34
 
31
- static const int httpclient_parser_en_main = 1;
35
+ static const short _httpclient_parser_key_offsets[] = {
36
+ 0, 10, 10, 11, 22, 26, 27, 28,
37
+ 39, 54, 75, 90, 110, 125, 146, 161,
38
+ 181, 196, 214, 229, 246, 247, 248, 249,
39
+ 250, 252, 255, 257, 260, 262, 264, 266,
40
+ 268, 269, 270, 286, 302, 304, 305, 306
41
+ };
42
+
43
+ static const char _httpclient_parser_trans_keys[] = {
44
+ 13, 48, 59, 72, 49, 57, 65, 70,
45
+ 97, 102, 10, 13, 32, 59, 9, 12,
46
+ 48, 57, 65, 70, 97, 102, 13, 32,
47
+ 9, 12, 10, 10, 13, 32, 59, 9,
48
+ 12, 48, 57, 65, 70, 97, 102, 33,
49
+ 124, 126, 35, 39, 42, 43, 45, 46,
50
+ 48, 57, 65, 90, 94, 122, 13, 32,
51
+ 33, 59, 61, 124, 126, 9, 12, 35,
52
+ 39, 42, 43, 45, 46, 48, 57, 65,
53
+ 90, 94, 122, 33, 124, 126, 35, 39,
54
+ 42, 43, 45, 46, 48, 57, 65, 90,
55
+ 94, 122, 13, 32, 33, 59, 124, 126,
56
+ 9, 12, 35, 39, 42, 43, 45, 46,
57
+ 48, 57, 65, 90, 94, 122, 33, 124,
58
+ 126, 35, 39, 42, 43, 45, 46, 48,
59
+ 57, 65, 90, 94, 122, 13, 32, 33,
60
+ 59, 61, 124, 126, 9, 12, 35, 39,
61
+ 42, 43, 45, 46, 48, 57, 65, 90,
62
+ 94, 122, 33, 124, 126, 35, 39, 42,
63
+ 43, 45, 46, 48, 57, 65, 90, 94,
64
+ 122, 13, 32, 33, 59, 124, 126, 9,
65
+ 12, 35, 39, 42, 43, 45, 46, 48,
66
+ 57, 65, 90, 94, 122, 33, 124, 126,
67
+ 35, 39, 42, 43, 45, 46, 48, 57,
68
+ 65, 90, 94, 122, 13, 33, 59, 61,
69
+ 124, 126, 35, 39, 42, 43, 45, 46,
70
+ 48, 57, 65, 90, 94, 122, 33, 124,
71
+ 126, 35, 39, 42, 43, 45, 46, 48,
72
+ 57, 65, 90, 94, 122, 13, 33, 59,
73
+ 124, 126, 35, 39, 42, 43, 45, 46,
74
+ 48, 57, 65, 90, 94, 122, 84, 84,
75
+ 80, 47, 48, 57, 46, 48, 57, 48,
76
+ 57, 32, 48, 57, 48, 57, 48, 57,
77
+ 48, 57, 13, 32, 13, 10, 13, 33,
78
+ 124, 126, 35, 39, 42, 43, 45, 46,
79
+ 48, 57, 65, 90, 94, 122, 33, 58,
80
+ 124, 126, 35, 39, 42, 43, 45, 46,
81
+ 48, 57, 65, 90, 94, 122, 13, 32,
82
+ 13, 13, 0
83
+ };
84
+
85
+ static const char _httpclient_parser_single_lengths[] = {
86
+ 4, 0, 1, 3, 2, 1, 1, 3,
87
+ 3, 7, 3, 6, 3, 7, 3, 6,
88
+ 3, 6, 3, 5, 1, 1, 1, 1,
89
+ 0, 1, 0, 1, 0, 0, 0, 2,
90
+ 1, 1, 4, 4, 2, 1, 1, 0
91
+ };
92
+
93
+ static const char _httpclient_parser_range_lengths[] = {
94
+ 3, 0, 0, 4, 1, 0, 0, 4,
95
+ 6, 7, 6, 7, 6, 7, 6, 7,
96
+ 6, 6, 6, 6, 0, 0, 0, 0,
97
+ 1, 1, 1, 1, 1, 1, 1, 0,
98
+ 0, 0, 6, 6, 0, 0, 0, 0
99
+ };
100
+
101
+ static const unsigned char _httpclient_parser_index_offsets[] = {
102
+ 0, 8, 8, 10, 18, 22, 24, 26,
103
+ 34, 44, 59, 69, 83, 93, 108, 118,
104
+ 132, 142, 155, 165, 177, 179, 181, 183,
105
+ 185, 187, 190, 192, 195, 197, 199, 201,
106
+ 204, 206, 208, 219, 230, 233, 235, 237
107
+ };
108
+
109
+ static const char _httpclient_parser_indicies[] = {
110
+ 14, 15, 17, 18, 16, 16, 16, 0,
111
+ 30, 0, 63, 37, 64, 37, 39, 39,
112
+ 39, 0, 19, 32, 32, 0, 29, 0,
113
+ 31, 0, 38, 37, 40, 37, 39, 39,
114
+ 39, 0, 58, 58, 58, 58, 58, 58,
115
+ 58, 58, 58, 0, 42, 41, 43, 44,
116
+ 45, 43, 43, 41, 43, 43, 43, 43,
117
+ 43, 43, 0, 59, 59, 59, 59, 59,
118
+ 59, 59, 59, 59, 0, 34, 33, 35,
119
+ 36, 35, 35, 33, 35, 35, 35, 35,
120
+ 35, 35, 0, 70, 70, 70, 70, 70,
121
+ 70, 70, 70, 70, 0, 65, 41, 66,
122
+ 67, 68, 66, 66, 41, 66, 66, 66,
123
+ 66, 66, 66, 0, 69, 69, 69, 69,
124
+ 69, 69, 69, 69, 69, 0, 60, 33,
125
+ 61, 62, 61, 61, 33, 61, 61, 61,
126
+ 61, 61, 61, 0, 10, 10, 10, 10,
127
+ 10, 10, 10, 10, 10, 0, 24, 25,
128
+ 26, 27, 25, 25, 25, 25, 25, 25,
129
+ 25, 25, 0, 11, 11, 11, 11, 11,
130
+ 11, 11, 11, 11, 0, 21, 22, 23,
131
+ 22, 22, 22, 22, 22, 22, 22, 22,
132
+ 0, 1, 0, 56, 0, 2, 0, 5,
133
+ 0, 7, 0, 6, 7, 0, 13, 0,
134
+ 12, 13, 0, 4, 0, 3, 0, 57,
135
+ 0, 54, 55, 53, 49, 48, 28, 0,
136
+ 19, 20, 20, 20, 20, 20, 20, 20,
137
+ 20, 20, 0, 8, 9, 8, 8, 8,
138
+ 8, 8, 8, 8, 8, 0, 47, 52,
139
+ 51, 47, 46, 49, 50, 0, 0
140
+ };
141
+
142
+ static const char _httpclient_parser_trans_targs_wi[] = {
143
+ 1, 21, 23, 30, 29, 24, 26, 25,
144
+ 35, 36, 17, 19, 28, 27, 2, 3,
145
+ 7, 16, 20, 5, 35, 2, 19, 16,
146
+ 2, 17, 16, 18, 34, 39, 39, 39,
147
+ 4, 4, 5, 11, 8, 4, 5, 7,
148
+ 8, 4, 5, 9, 8, 10, 37, 33,
149
+ 32, 33, 32, 37, 36, 32, 33, 38,
150
+ 22, 31, 9, 11, 6, 15, 12, 6,
151
+ 12, 6, 13, 12, 14, 15, 13
152
+ };
153
+
154
+ static const char _httpclient_parser_trans_actions_wi[] = {
155
+ 0, 0, 0, 0, 1, 0, 0, 0,
156
+ 0, 5, 3, 7, 13, 0, 0, 1,
157
+ 1, 0, 1, 0, 3, 9, 0, 9,
158
+ 34, 0, 34, 19, 0, 17, 28, 31,
159
+ 0, 9, 9, 0, 9, 15, 15, 0,
160
+ 15, 34, 34, 0, 34, 19, 0, 9,
161
+ 0, 11, 1, 7, 7, 22, 25, 22,
162
+ 0, 0, 3, 7, 9, 0, 9, 15,
163
+ 15, 34, 0, 34, 19, 7, 3
164
+ };
165
+
166
+ static const int httpclient_parser_start = 0;
167
+
168
+ static const int httpclient_parser_first_final = 39;
169
+
170
+ static const int httpclient_parser_error = 1;
32
171
 
33
172
  #line 99 "http11_parser.rl"
34
173
 
35
174
  int httpclient_parser_init(httpclient_parser *parser) {
36
175
  int cs = 0;
37
176
 
38
- #line 39 "http11_parser.c"
177
+ #line 178 "http11_parser.c"
39
178
  {
40
179
  cs = httpclient_parser_start;
41
180
  }
@@ -67,999 +206,150 @@ size_t httpclient_parser_execute(httpclient_parser *parser, const char *buffer,
67
206
 
68
207
 
69
208
 
70
- #line 71 "http11_parser.c"
209
+ #line 210 "http11_parser.c"
71
210
  {
211
+ int _klen;
212
+ unsigned int _trans;
213
+ const char *_acts;
214
+ unsigned int _nacts;
215
+ const char *_keys;
216
+
72
217
  if ( p == pe )
73
218
  goto _out;
74
- switch ( cs )
75
- {
76
- case 1:
77
- switch( (*p) ) {
78
- case 13: goto st2;
79
- case 48: goto tr2;
80
- case 59: goto st16;
81
- case 72: goto tr5;
82
- }
83
- if ( (*p) < 65 ) {
84
- if ( 49 <= (*p) && (*p) <= 57 )
85
- goto tr3;
86
- } else if ( (*p) > 70 ) {
87
- if ( 97 <= (*p) && (*p) <= 102 )
88
- goto tr3;
89
- } else
90
- goto tr3;
91
- goto st0;
92
- st0:
93
- goto _out0;
94
- tr38:
95
- #line 27 "http11_parser.rl"
96
- {
97
- parser->field_len = LEN(field_start, p);
98
- }
99
- #line 31 "http11_parser.rl"
100
- { MARK(mark, p); }
101
- #line 33 "http11_parser.rl"
102
- {
103
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
104
- }
105
- goto st2;
106
- tr43:
107
- #line 33 "http11_parser.rl"
108
- {
109
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
110
- }
111
- goto st2;
112
- st2:
113
- if ( ++p == pe )
114
- goto _out2;
115
- case 2:
116
- #line 117 "http11_parser.c"
117
- if ( (*p) == 10 )
118
- goto tr6;
119
- goto st0;
120
- tr6:
121
- #line 53 "http11_parser.rl"
122
- {
123
- parser->last_chunk(parser->data, NULL, 0);
124
- }
125
- #line 57 "http11_parser.rl"
126
- {
127
- parser->body_start = p - buffer + 1;
128
- if(parser->header_done != NULL)
129
- parser->header_done(parser->data, p + 1, pe - p - 1);
130
- goto _out37;
131
- }
132
- goto st37;
133
- tr13:
134
- #line 57 "http11_parser.rl"
135
- {
136
- parser->body_start = p - buffer + 1;
137
- if(parser->header_done != NULL)
138
- parser->header_done(parser->data, p + 1, pe - p - 1);
139
- goto _out37;
140
- }
141
- goto st37;
142
- tr14:
143
- #line 57 "http11_parser.rl"
144
- {
145
- parser->body_start = p - buffer + 1;
146
- if(parser->header_done != NULL)
147
- parser->header_done(parser->data, p + 1, pe - p - 1);
148
- goto _out37;
149
- }
150
- #line 53 "http11_parser.rl"
151
- {
152
- parser->last_chunk(parser->data, NULL, 0);
153
- }
154
- goto st37;
155
- st37:
156
- if ( ++p == pe )
157
- goto _out37;
158
- case 37:
159
- #line 160 "http11_parser.c"
160
- goto st0;
161
- tr2:
162
- #line 23 "http11_parser.rl"
163
- {MARK(mark, p); }
164
- goto st3;
165
- st3:
166
- if ( ++p == pe )
167
- goto _out3;
168
- case 3:
169
- #line 170 "http11_parser.c"
170
- switch( (*p) ) {
171
- case 13: goto tr8;
172
- case 32: goto tr7;
173
- case 59: goto tr10;
219
+ _resume:
220
+ if ( cs == 1 )
221
+ goto _out;
222
+ _keys = _httpclient_parser_trans_keys + _httpclient_parser_key_offsets[cs];
223
+ _trans = _httpclient_parser_index_offsets[cs];
224
+
225
+ _klen = _httpclient_parser_single_lengths[cs];
226
+ if ( _klen > 0 ) {
227
+ const char *_lower = _keys;
228
+ const char *_mid;
229
+ const char *_upper = _keys + _klen - 1;
230
+ while (1) {
231
+ if ( _upper < _lower )
232
+ break;
233
+
234
+ _mid = _lower + ((_upper-_lower) >> 1);
235
+ if ( (*p) < *_mid )
236
+ _upper = _mid - 1;
237
+ else if ( (*p) > *_mid )
238
+ _lower = _mid + 1;
239
+ else {
240
+ _trans += (_mid - _keys);
241
+ goto _match;
242
+ }
243
+ }
244
+ _keys += _klen;
245
+ _trans += _klen;
174
246
  }
175
- if ( (*p) < 48 ) {
176
- if ( 9 <= (*p) && (*p) <= 12 )
177
- goto tr7;
178
- } else if ( (*p) > 57 ) {
179
- if ( (*p) > 70 ) {
180
- if ( 97 <= (*p) && (*p) <= 102 )
181
- goto st7;
182
- } else if ( (*p) >= 65 )
183
- goto st7;
184
- } else
185
- goto st7;
186
- goto st0;
187
- tr7:
188
- #line 49 "http11_parser.rl"
189
- {
190
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
191
- }
192
- goto st4;
193
- tr18:
194
- #line 27 "http11_parser.rl"
195
- {
196
- parser->field_len = LEN(field_start, p);
197
- }
198
- #line 31 "http11_parser.rl"
199
- { MARK(mark, p); }
200
- #line 33 "http11_parser.rl"
201
- {
202
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
203
- }
204
- goto st4;
205
- tr24:
206
- #line 33 "http11_parser.rl"
207
- {
208
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
209
- }
210
- goto st4;
211
- st4:
212
- if ( ++p == pe )
213
- goto _out4;
214
- case 4:
215
- #line 216 "http11_parser.c"
216
- switch( (*p) ) {
217
- case 13: goto st5;
218
- case 32: goto st4;
247
+
248
+ _klen = _httpclient_parser_range_lengths[cs];
249
+ if ( _klen > 0 ) {
250
+ const char *_lower = _keys;
251
+ const char *_mid;
252
+ const char *_upper = _keys + (_klen<<1) - 2;
253
+ while (1) {
254
+ if ( _upper < _lower )
255
+ break;
256
+
257
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
258
+ if ( (*p) < _mid[0] )
259
+ _upper = _mid - 2;
260
+ else if ( (*p) > _mid[1] )
261
+ _lower = _mid + 2;
262
+ else {
263
+ _trans += ((_mid - _keys)>>1);
264
+ goto _match;
265
+ }
266
+ }
267
+ _trans += _klen;
219
268
  }
220
- if ( 9 <= (*p) && (*p) <= 12 )
221
- goto st4;
222
- goto st0;
223
- tr15:
224
- #line 49 "http11_parser.rl"
225
- {
226
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
227
- }
228
- goto st5;
229
- tr19:
230
- #line 27 "http11_parser.rl"
231
- {
232
- parser->field_len = LEN(field_start, p);
233
- }
234
- #line 31 "http11_parser.rl"
235
- { MARK(mark, p); }
236
- #line 33 "http11_parser.rl"
237
- {
238
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
239
- }
240
- goto st5;
241
- tr25:
242
- #line 33 "http11_parser.rl"
243
- {
244
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
245
- }
246
- goto st5;
247
- st5:
248
- if ( ++p == pe )
249
- goto _out5;
250
- case 5:
251
- #line 252 "http11_parser.c"
252
- if ( (*p) == 10 )
253
- goto tr13;
254
- goto st0;
255
- tr8:
256
- #line 49 "http11_parser.rl"
269
+
270
+ _match:
271
+ _trans = _httpclient_parser_indicies[_trans];
272
+ cs = _httpclient_parser_trans_targs_wi[_trans];
273
+
274
+ if ( _httpclient_parser_trans_actions_wi[_trans] == 0 )
275
+ goto _again;
276
+
277
+ _acts = _httpclient_parser_actions + _httpclient_parser_trans_actions_wi[_trans];
278
+ _nacts = (unsigned int) *_acts++;
279
+ while ( _nacts-- > 0 )
257
280
  {
258
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
259
- }
260
- goto st6;
261
- tr29:
262
- #line 27 "http11_parser.rl"
263
- {
264
- parser->field_len = LEN(field_start, p);
265
- }
266
- #line 31 "http11_parser.rl"
267
- { MARK(mark, p); }
268
- #line 33 "http11_parser.rl"
269
- {
270
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
271
- }
272
- goto st6;
273
- tr34:
274
- #line 33 "http11_parser.rl"
275
- {
276
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
277
- }
278
- goto st6;
279
- st6:
280
- if ( ++p == pe )
281
- goto _out6;
282
- case 6:
283
- #line 284 "http11_parser.c"
284
- if ( (*p) == 10 )
285
- goto tr14;
286
- goto st0;
287
- tr3:
281
+ switch ( *_acts++ )
282
+ {
283
+ case 0:
288
284
  #line 23 "http11_parser.rl"
289
285
  {MARK(mark, p); }
290
- goto st7;
291
- st7:
292
- if ( ++p == pe )
293
- goto _out7;
294
- case 7:
295
- #line 296 "http11_parser.c"
296
- switch( (*p) ) {
297
- case 13: goto tr15;
298
- case 32: goto tr7;
299
- case 59: goto tr16;
300
- }
301
- if ( (*p) < 48 ) {
302
- if ( 9 <= (*p) && (*p) <= 12 )
303
- goto tr7;
304
- } else if ( (*p) > 57 ) {
305
- if ( (*p) > 70 ) {
306
- if ( 97 <= (*p) && (*p) <= 102 )
307
- goto st7;
308
- } else if ( (*p) >= 65 )
309
- goto st7;
310
- } else
311
- goto st7;
312
- goto st0;
313
- tr16:
314
- #line 49 "http11_parser.rl"
315
- {
316
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
317
- }
318
- goto st8;
319
- tr21:
320
- #line 27 "http11_parser.rl"
321
- {
322
- parser->field_len = LEN(field_start, p);
323
- }
324
- #line 31 "http11_parser.rl"
325
- { MARK(mark, p); }
326
- #line 33 "http11_parser.rl"
327
- {
328
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
329
- }
330
- goto st8;
331
- tr27:
332
- #line 33 "http11_parser.rl"
333
- {
334
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
335
- }
336
- goto st8;
337
- st8:
338
- if ( ++p == pe )
339
- goto _out8;
340
- case 8:
341
- #line 342 "http11_parser.c"
342
- switch( (*p) ) {
343
- case 33: goto tr17;
344
- case 124: goto tr17;
345
- case 126: goto tr17;
346
- }
347
- if ( (*p) < 45 ) {
348
- if ( (*p) > 39 ) {
349
- if ( 42 <= (*p) && (*p) <= 43 )
350
- goto tr17;
351
- } else if ( (*p) >= 35 )
352
- goto tr17;
353
- } else if ( (*p) > 46 ) {
354
- if ( (*p) < 65 ) {
355
- if ( 48 <= (*p) && (*p) <= 57 )
356
- goto tr17;
357
- } else if ( (*p) > 90 ) {
358
- if ( 94 <= (*p) && (*p) <= 122 )
359
- goto tr17;
360
- } else
361
- goto tr17;
362
- } else
363
- goto tr17;
364
- goto st0;
365
- tr17:
286
+ break;
287
+ case 1:
366
288
  #line 25 "http11_parser.rl"
367
289
  { MARK(field_start, p); }
368
- goto st9;
369
- st9:
370
- if ( ++p == pe )
371
- goto _out9;
372
- case 9:
373
- #line 374 "http11_parser.c"
374
- switch( (*p) ) {
375
- case 13: goto tr19;
376
- case 32: goto tr18;
377
- case 33: goto st9;
378
- case 59: goto tr21;
379
- case 61: goto tr22;
380
- case 124: goto st9;
381
- case 126: goto st9;
382
- }
383
- if ( (*p) < 45 ) {
384
- if ( (*p) < 35 ) {
385
- if ( 9 <= (*p) && (*p) <= 12 )
386
- goto tr18;
387
- } else if ( (*p) > 39 ) {
388
- if ( 42 <= (*p) && (*p) <= 43 )
389
- goto st9;
390
- } else
391
- goto st9;
392
- } else if ( (*p) > 46 ) {
393
- if ( (*p) < 65 ) {
394
- if ( 48 <= (*p) && (*p) <= 57 )
395
- goto st9;
396
- } else if ( (*p) > 90 ) {
397
- if ( 94 <= (*p) && (*p) <= 122 )
398
- goto st9;
399
- } else
400
- goto st9;
401
- } else
402
- goto st9;
403
- goto st0;
404
- tr22:
290
+ break;
291
+ case 2:
405
292
  #line 27 "http11_parser.rl"
406
293
  {
407
294
  parser->field_len = LEN(field_start, p);
408
295
  }
296
+ break;
297
+ case 3:
409
298
  #line 31 "http11_parser.rl"
410
299
  { MARK(mark, p); }
411
- goto st10;
412
- st10:
413
- if ( ++p == pe )
414
- goto _out10;
415
- case 10:
416
- #line 417 "http11_parser.c"
417
- switch( (*p) ) {
418
- case 33: goto tr23;
419
- case 124: goto tr23;
420
- case 126: goto tr23;
421
- }
422
- if ( (*p) < 45 ) {
423
- if ( (*p) > 39 ) {
424
- if ( 42 <= (*p) && (*p) <= 43 )
425
- goto tr23;
426
- } else if ( (*p) >= 35 )
427
- goto tr23;
428
- } else if ( (*p) > 46 ) {
429
- if ( (*p) < 65 ) {
430
- if ( 48 <= (*p) && (*p) <= 57 )
431
- goto tr23;
432
- } else if ( (*p) > 90 ) {
433
- if ( 94 <= (*p) && (*p) <= 122 )
434
- goto tr23;
435
- } else
436
- goto tr23;
437
- } else
438
- goto tr23;
439
- goto st0;
440
- tr23:
441
- #line 31 "http11_parser.rl"
442
- { MARK(mark, p); }
443
- goto st11;
444
- st11:
445
- if ( ++p == pe )
446
- goto _out11;
447
- case 11:
448
- #line 449 "http11_parser.c"
449
- switch( (*p) ) {
450
- case 13: goto tr25;
451
- case 32: goto tr24;
452
- case 33: goto st11;
453
- case 59: goto tr27;
454
- case 124: goto st11;
455
- case 126: goto st11;
456
- }
457
- if ( (*p) < 45 ) {
458
- if ( (*p) < 35 ) {
459
- if ( 9 <= (*p) && (*p) <= 12 )
460
- goto tr24;
461
- } else if ( (*p) > 39 ) {
462
- if ( 42 <= (*p) && (*p) <= 43 )
463
- goto st11;
464
- } else
465
- goto st11;
466
- } else if ( (*p) > 46 ) {
467
- if ( (*p) < 65 ) {
468
- if ( 48 <= (*p) && (*p) <= 57 )
469
- goto st11;
470
- } else if ( (*p) > 90 ) {
471
- if ( 94 <= (*p) && (*p) <= 122 )
472
- goto st11;
473
- } else
474
- goto st11;
475
- } else
476
- goto st11;
477
- goto st0;
478
- tr10:
479
- #line 49 "http11_parser.rl"
480
- {
481
- parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
482
- }
483
- goto st12;
484
- tr31:
485
- #line 27 "http11_parser.rl"
486
- {
487
- parser->field_len = LEN(field_start, p);
488
- }
489
- #line 31 "http11_parser.rl"
490
- { MARK(mark, p); }
491
- #line 33 "http11_parser.rl"
492
- {
493
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
494
- }
495
- goto st12;
496
- tr36:
300
+ break;
301
+ case 4:
497
302
  #line 33 "http11_parser.rl"
498
303
  {
499
304
  parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
500
305
  }
501
- goto st12;
502
- st12:
503
- if ( ++p == pe )
504
- goto _out12;
505
- case 12:
506
- #line 507 "http11_parser.c"
507
- switch( (*p) ) {
508
- case 33: goto tr28;
509
- case 124: goto tr28;
510
- case 126: goto tr28;
511
- }
512
- if ( (*p) < 45 ) {
513
- if ( (*p) > 39 ) {
514
- if ( 42 <= (*p) && (*p) <= 43 )
515
- goto tr28;
516
- } else if ( (*p) >= 35 )
517
- goto tr28;
518
- } else if ( (*p) > 46 ) {
519
- if ( (*p) < 65 ) {
520
- if ( 48 <= (*p) && (*p) <= 57 )
521
- goto tr28;
522
- } else if ( (*p) > 90 ) {
523
- if ( 94 <= (*p) && (*p) <= 122 )
524
- goto tr28;
525
- } else
526
- goto tr28;
527
- } else
528
- goto tr28;
529
- goto st0;
530
- tr28:
531
- #line 25 "http11_parser.rl"
532
- { MARK(field_start, p); }
533
- goto st13;
534
- st13:
535
- if ( ++p == pe )
536
- goto _out13;
537
- case 13:
538
- #line 539 "http11_parser.c"
539
- switch( (*p) ) {
540
- case 13: goto tr29;
541
- case 32: goto tr18;
542
- case 33: goto st13;
543
- case 59: goto tr31;
544
- case 61: goto tr32;
545
- case 124: goto st13;
546
- case 126: goto st13;
547
- }
548
- if ( (*p) < 45 ) {
549
- if ( (*p) < 35 ) {
550
- if ( 9 <= (*p) && (*p) <= 12 )
551
- goto tr18;
552
- } else if ( (*p) > 39 ) {
553
- if ( 42 <= (*p) && (*p) <= 43 )
554
- goto st13;
555
- } else
556
- goto st13;
557
- } else if ( (*p) > 46 ) {
558
- if ( (*p) < 65 ) {
559
- if ( 48 <= (*p) && (*p) <= 57 )
560
- goto st13;
561
- } else if ( (*p) > 90 ) {
562
- if ( 94 <= (*p) && (*p) <= 122 )
563
- goto st13;
564
- } else
565
- goto st13;
566
- } else
567
- goto st13;
568
- goto st0;
569
- tr32:
570
- #line 27 "http11_parser.rl"
571
- {
572
- parser->field_len = LEN(field_start, p);
573
- }
574
- #line 31 "http11_parser.rl"
575
- { MARK(mark, p); }
576
- goto st14;
577
- st14:
578
- if ( ++p == pe )
579
- goto _out14;
580
- case 14:
581
- #line 582 "http11_parser.c"
582
- switch( (*p) ) {
583
- case 33: goto tr33;
584
- case 124: goto tr33;
585
- case 126: goto tr33;
586
- }
587
- if ( (*p) < 45 ) {
588
- if ( (*p) > 39 ) {
589
- if ( 42 <= (*p) && (*p) <= 43 )
590
- goto tr33;
591
- } else if ( (*p) >= 35 )
592
- goto tr33;
593
- } else if ( (*p) > 46 ) {
594
- if ( (*p) < 65 ) {
595
- if ( 48 <= (*p) && (*p) <= 57 )
596
- goto tr33;
597
- } else if ( (*p) > 90 ) {
598
- if ( 94 <= (*p) && (*p) <= 122 )
599
- goto tr33;
600
- } else
601
- goto tr33;
602
- } else
603
- goto tr33;
604
- goto st0;
605
- tr33:
606
- #line 31 "http11_parser.rl"
607
- { MARK(mark, p); }
608
- goto st15;
609
- st15:
610
- if ( ++p == pe )
611
- goto _out15;
612
- case 15:
613
- #line 614 "http11_parser.c"
614
- switch( (*p) ) {
615
- case 13: goto tr34;
616
- case 32: goto tr24;
617
- case 33: goto st15;
618
- case 59: goto tr36;
619
- case 124: goto st15;
620
- case 126: goto st15;
621
- }
622
- if ( (*p) < 45 ) {
623
- if ( (*p) < 35 ) {
624
- if ( 9 <= (*p) && (*p) <= 12 )
625
- goto tr24;
626
- } else if ( (*p) > 39 ) {
627
- if ( 42 <= (*p) && (*p) <= 43 )
628
- goto st15;
629
- } else
630
- goto st15;
631
- } else if ( (*p) > 46 ) {
632
- if ( (*p) < 65 ) {
633
- if ( 48 <= (*p) && (*p) <= 57 )
634
- goto st15;
635
- } else if ( (*p) > 90 ) {
636
- if ( 94 <= (*p) && (*p) <= 122 )
637
- goto st15;
638
- } else
639
- goto st15;
640
- } else
641
- goto st15;
642
- goto st0;
643
- tr40:
644
- #line 27 "http11_parser.rl"
645
- {
646
- parser->field_len = LEN(field_start, p);
647
- }
648
- #line 31 "http11_parser.rl"
649
- { MARK(mark, p); }
650
- #line 33 "http11_parser.rl"
651
- {
652
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
653
- }
654
- goto st16;
655
- tr45:
656
- #line 33 "http11_parser.rl"
306
+ break;
307
+ case 5:
308
+ #line 37 "http11_parser.rl"
657
309
  {
658
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
310
+ parser->reason_phrase(parser->data, PTR_TO(mark), LEN(mark, p));
659
311
  }
660
- goto st16;
661
- st16:
662
- if ( ++p == pe )
663
- goto _out16;
664
- case 16:
665
- #line 666 "http11_parser.c"
666
- switch( (*p) ) {
667
- case 33: goto tr37;
668
- case 124: goto tr37;
669
- case 126: goto tr37;
670
- }
671
- if ( (*p) < 45 ) {
672
- if ( (*p) > 39 ) {
673
- if ( 42 <= (*p) && (*p) <= 43 )
674
- goto tr37;
675
- } else if ( (*p) >= 35 )
676
- goto tr37;
677
- } else if ( (*p) > 46 ) {
678
- if ( (*p) < 65 ) {
679
- if ( 48 <= (*p) && (*p) <= 57 )
680
- goto tr37;
681
- } else if ( (*p) > 90 ) {
682
- if ( 94 <= (*p) && (*p) <= 122 )
683
- goto tr37;
684
- } else
685
- goto tr37;
686
- } else
687
- goto tr37;
688
- goto st0;
689
- tr37:
690
- #line 25 "http11_parser.rl"
691
- { MARK(field_start, p); }
692
- goto st17;
693
- st17:
694
- if ( ++p == pe )
695
- goto _out17;
696
- case 17:
697
- #line 698 "http11_parser.c"
698
- switch( (*p) ) {
699
- case 13: goto tr38;
700
- case 33: goto st17;
701
- case 59: goto tr40;
702
- case 61: goto tr41;
703
- case 124: goto st17;
704
- case 126: goto st17;
705
- }
706
- if ( (*p) < 45 ) {
707
- if ( (*p) > 39 ) {
708
- if ( 42 <= (*p) && (*p) <= 43 )
709
- goto st17;
710
- } else if ( (*p) >= 35 )
711
- goto st17;
712
- } else if ( (*p) > 46 ) {
713
- if ( (*p) < 65 ) {
714
- if ( 48 <= (*p) && (*p) <= 57 )
715
- goto st17;
716
- } else if ( (*p) > 90 ) {
717
- if ( 94 <= (*p) && (*p) <= 122 )
718
- goto st17;
719
- } else
720
- goto st17;
721
- } else
722
- goto st17;
723
- goto st0;
724
- tr41:
725
- #line 27 "http11_parser.rl"
312
+ break;
313
+ case 6:
314
+ #line 41 "http11_parser.rl"
726
315
  {
727
- parser->field_len = LEN(field_start, p);
316
+ parser->status_code(parser->data, PTR_TO(mark), LEN(mark, p));
728
317
  }
729
- #line 31 "http11_parser.rl"
730
- { MARK(mark, p); }
731
- goto st18;
732
- st18:
733
- if ( ++p == pe )
734
- goto _out18;
735
- case 18:
736
- #line 737 "http11_parser.c"
737
- switch( (*p) ) {
738
- case 33: goto tr42;
739
- case 124: goto tr42;
740
- case 126: goto tr42;
741
- }
742
- if ( (*p) < 45 ) {
743
- if ( (*p) > 39 ) {
744
- if ( 42 <= (*p) && (*p) <= 43 )
745
- goto tr42;
746
- } else if ( (*p) >= 35 )
747
- goto tr42;
748
- } else if ( (*p) > 46 ) {
749
- if ( (*p) < 65 ) {
750
- if ( 48 <= (*p) && (*p) <= 57 )
751
- goto tr42;
752
- } else if ( (*p) > 90 ) {
753
- if ( 94 <= (*p) && (*p) <= 122 )
754
- goto tr42;
755
- } else
756
- goto tr42;
757
- } else
758
- goto tr42;
759
- goto st0;
760
- tr42:
761
- #line 31 "http11_parser.rl"
762
- { MARK(mark, p); }
763
- goto st19;
764
- st19:
765
- if ( ++p == pe )
766
- goto _out19;
767
- case 19:
768
- #line 769 "http11_parser.c"
769
- switch( (*p) ) {
770
- case 13: goto tr43;
771
- case 33: goto st19;
772
- case 59: goto tr45;
773
- case 124: goto st19;
774
- case 126: goto st19;
775
- }
776
- if ( (*p) < 45 ) {
777
- if ( (*p) > 39 ) {
778
- if ( 42 <= (*p) && (*p) <= 43 )
779
- goto st19;
780
- } else if ( (*p) >= 35 )
781
- goto st19;
782
- } else if ( (*p) > 46 ) {
783
- if ( (*p) < 65 ) {
784
- if ( 48 <= (*p) && (*p) <= 57 )
785
- goto st19;
786
- } else if ( (*p) > 90 ) {
787
- if ( 94 <= (*p) && (*p) <= 122 )
788
- goto st19;
789
- } else
790
- goto st19;
791
- } else
792
- goto st19;
793
- goto st0;
794
- tr5:
795
- #line 23 "http11_parser.rl"
796
- {MARK(mark, p); }
797
- goto st20;
798
- st20:
799
- if ( ++p == pe )
800
- goto _out20;
801
- case 20:
802
- #line 803 "http11_parser.c"
803
- if ( (*p) == 84 )
804
- goto st21;
805
- goto st0;
806
- st21:
807
- if ( ++p == pe )
808
- goto _out21;
809
- case 21:
810
- if ( (*p) == 84 )
811
- goto st22;
812
- goto st0;
813
- st22:
814
- if ( ++p == pe )
815
- goto _out22;
816
- case 22:
817
- if ( (*p) == 80 )
818
- goto st23;
819
- goto st0;
820
- st23:
821
- if ( ++p == pe )
822
- goto _out23;
823
- case 23:
824
- if ( (*p) == 47 )
825
- goto st24;
826
- goto st0;
827
- st24:
828
- if ( ++p == pe )
829
- goto _out24;
830
- case 24:
831
- if ( 48 <= (*p) && (*p) <= 57 )
832
- goto st25;
833
- goto st0;
834
- st25:
835
- if ( ++p == pe )
836
- goto _out25;
837
- case 25:
838
- if ( (*p) == 46 )
839
- goto st26;
840
- if ( 48 <= (*p) && (*p) <= 57 )
841
- goto st25;
842
- goto st0;
843
- st26:
844
- if ( ++p == pe )
845
- goto _out26;
846
- case 26:
847
- if ( 48 <= (*p) && (*p) <= 57 )
848
- goto st27;
849
- goto st0;
850
- st27:
851
- if ( ++p == pe )
852
- goto _out27;
853
- case 27:
854
- if ( (*p) == 32 )
855
- goto tr53;
856
- if ( 48 <= (*p) && (*p) <= 57 )
857
- goto st27;
858
- goto st0;
859
- tr53:
318
+ break;
319
+ case 7:
860
320
  #line 45 "http11_parser.rl"
861
321
  {
862
322
  parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p));
863
323
  }
864
- goto st28;
865
- st28:
866
- if ( ++p == pe )
867
- goto _out28;
868
- case 28:
869
- #line 870 "http11_parser.c"
870
- if ( 48 <= (*p) && (*p) <= 57 )
871
- goto tr54;
872
- goto st0;
873
- tr54:
874
- #line 23 "http11_parser.rl"
875
- {MARK(mark, p); }
876
- goto st29;
877
- st29:
878
- if ( ++p == pe )
879
- goto _out29;
880
- case 29:
881
- #line 882 "http11_parser.c"
882
- if ( (*p) == 32 )
883
- goto tr55;
884
- if ( 48 <= (*p) && (*p) <= 57 )
885
- goto st29;
886
- goto st0;
887
- tr55:
888
- #line 41 "http11_parser.rl"
889
- {
890
- parser->status_code(parser->data, PTR_TO(mark), LEN(mark, p));
891
- }
892
- goto st30;
893
- st30:
894
- if ( ++p == pe )
895
- goto _out30;
896
- case 30:
897
- #line 898 "http11_parser.c"
898
- goto tr57;
899
- tr57:
900
- #line 23 "http11_parser.rl"
901
- {MARK(mark, p); }
902
- goto st31;
903
- st31:
904
- if ( ++p == pe )
905
- goto _out31;
906
- case 31:
907
- #line 908 "http11_parser.c"
908
- if ( (*p) == 13 )
909
- goto tr59;
910
- goto st31;
911
- tr65:
912
- #line 33 "http11_parser.rl"
913
- {
914
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
324
+ break;
325
+ case 8:
326
+ #line 49 "http11_parser.rl"
327
+ {
328
+ parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
915
329
  }
916
- goto st32;
917
- tr59:
918
- #line 37 "http11_parser.rl"
919
- {
920
- parser->reason_phrase(parser->data, PTR_TO(mark), LEN(mark, p));
330
+ break;
331
+ case 9:
332
+ #line 53 "http11_parser.rl"
333
+ {
334
+ parser->last_chunk(parser->data, NULL, 0);
921
335
  }
922
- goto st32;
923
- st32:
924
- if ( ++p == pe )
925
- goto _out32;
926
- case 32:
927
- #line 928 "http11_parser.c"
928
- if ( (*p) == 10 )
929
- goto st33;
930
- goto st0;
931
- st33:
932
- if ( ++p == pe )
933
- goto _out33;
934
- case 33:
935
- switch( (*p) ) {
936
- case 13: goto st5;
937
- case 33: goto tr61;
938
- case 124: goto tr61;
939
- case 126: goto tr61;
940
- }
941
- if ( (*p) < 45 ) {
942
- if ( (*p) > 39 ) {
943
- if ( 42 <= (*p) && (*p) <= 43 )
944
- goto tr61;
945
- } else if ( (*p) >= 35 )
946
- goto tr61;
947
- } else if ( (*p) > 46 ) {
948
- if ( (*p) < 65 ) {
949
- if ( 48 <= (*p) && (*p) <= 57 )
950
- goto tr61;
951
- } else if ( (*p) > 90 ) {
952
- if ( 94 <= (*p) && (*p) <= 122 )
953
- goto tr61;
954
- } else
955
- goto tr61;
956
- } else
957
- goto tr61;
958
- goto st0;
959
- tr61:
960
- #line 25 "http11_parser.rl"
961
- { MARK(field_start, p); }
962
- goto st34;
963
- st34:
964
- if ( ++p == pe )
965
- goto _out34;
966
- case 34:
967
- #line 968 "http11_parser.c"
968
- switch( (*p) ) {
969
- case 33: goto st34;
970
- case 58: goto tr63;
971
- case 124: goto st34;
972
- case 126: goto st34;
973
- }
974
- if ( (*p) < 45 ) {
975
- if ( (*p) > 39 ) {
976
- if ( 42 <= (*p) && (*p) <= 43 )
977
- goto st34;
978
- } else if ( (*p) >= 35 )
979
- goto st34;
980
- } else if ( (*p) > 46 ) {
981
- if ( (*p) < 65 ) {
982
- if ( 48 <= (*p) && (*p) <= 57 )
983
- goto st34;
984
- } else if ( (*p) > 90 ) {
985
- if ( 94 <= (*p) && (*p) <= 122 )
986
- goto st34;
987
- } else
988
- goto st34;
989
- } else
990
- goto st34;
991
- goto st0;
992
- tr66:
993
- #line 31 "http11_parser.rl"
994
- { MARK(mark, p); }
995
- goto st35;
996
- tr63:
997
- #line 27 "http11_parser.rl"
336
+ break;
337
+ case 10:
338
+ #line 57 "http11_parser.rl"
998
339
  {
999
- parser->field_len = LEN(field_start, p);
340
+ parser->body_start = p - buffer + 1;
341
+ if(parser->header_done != NULL)
342
+ parser->header_done(parser->data, p + 1, pe - p - 1);
343
+ goto _out;
1000
344
  }
1001
- goto st35;
1002
- st35:
1003
- if ( ++p == pe )
1004
- goto _out35;
1005
- case 35:
1006
- #line 1007 "http11_parser.c"
1007
- switch( (*p) ) {
1008
- case 13: goto tr65;
1009
- case 32: goto tr66;
1010
- }
1011
- goto tr64;
1012
- tr64:
1013
- #line 31 "http11_parser.rl"
1014
- { MARK(mark, p); }
1015
- goto st36;
1016
- st36:
1017
- if ( ++p == pe )
1018
- goto _out36;
1019
- case 36:
1020
- #line 1021 "http11_parser.c"
1021
- if ( (*p) == 13 )
1022
- goto tr65;
1023
- goto st36;
345
+ break;
346
+ #line 347 "http11_parser.c"
347
+ }
1024
348
  }
1025
- _out0: cs = 0; goto _out;
1026
- _out2: cs = 2; goto _out;
1027
- _out37: cs = 37; goto _out;
1028
- _out3: cs = 3; goto _out;
1029
- _out4: cs = 4; goto _out;
1030
- _out5: cs = 5; goto _out;
1031
- _out6: cs = 6; goto _out;
1032
- _out7: cs = 7; goto _out;
1033
- _out8: cs = 8; goto _out;
1034
- _out9: cs = 9; goto _out;
1035
- _out10: cs = 10; goto _out;
1036
- _out11: cs = 11; goto _out;
1037
- _out12: cs = 12; goto _out;
1038
- _out13: cs = 13; goto _out;
1039
- _out14: cs = 14; goto _out;
1040
- _out15: cs = 15; goto _out;
1041
- _out16: cs = 16; goto _out;
1042
- _out17: cs = 17; goto _out;
1043
- _out18: cs = 18; goto _out;
1044
- _out19: cs = 19; goto _out;
1045
- _out20: cs = 20; goto _out;
1046
- _out21: cs = 21; goto _out;
1047
- _out22: cs = 22; goto _out;
1048
- _out23: cs = 23; goto _out;
1049
- _out24: cs = 24; goto _out;
1050
- _out25: cs = 25; goto _out;
1051
- _out26: cs = 26; goto _out;
1052
- _out27: cs = 27; goto _out;
1053
- _out28: cs = 28; goto _out;
1054
- _out29: cs = 29; goto _out;
1055
- _out30: cs = 30; goto _out;
1056
- _out31: cs = 31; goto _out;
1057
- _out32: cs = 32; goto _out;
1058
- _out33: cs = 33; goto _out;
1059
- _out34: cs = 34; goto _out;
1060
- _out35: cs = 35; goto _out;
1061
- _out36: cs = 36; goto _out;
1062
349
 
350
+ _again:
351
+ if ( ++p != pe )
352
+ goto _resume;
1063
353
  _out: {}
1064
354
  }
1065
355
  #line 130 "http11_parser.rl"
@@ -1077,7 +367,7 @@ case 36:
1077
367
  if(parser->body_start) {
1078
368
  /* final \r\n combo encountered so stop right here */
1079
369
 
1080
- #line 1081 "http11_parser.c"
370
+ #line 371 "http11_parser.c"
1081
371
  #line 144 "http11_parser.rl"
1082
372
  parser->nread++;
1083
373
  }
@@ -1090,7 +380,7 @@ int httpclient_parser_finish(httpclient_parser *parser)
1090
380
  int cs = parser->cs;
1091
381
 
1092
382
 
1093
- #line 1094 "http11_parser.c"
383
+ #line 384 "http11_parser.c"
1094
384
  #line 155 "http11_parser.rl"
1095
385
 
1096
386
  parser->cs = cs;