rfuzz 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +55 -0
- data/LICENSE +55 -0
- data/README +252 -0
- data/Rakefile +48 -0
- data/doc/rdoc/classes/RFuzz.html +146 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.html +481 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000010.html +24 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000011.html +34 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000012.html +49 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000013.html +49 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000014.html +57 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000015.html +37 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000016.html +26 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000017.html +34 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000018.html +18 -0
- data/doc/rdoc/classes/RFuzz/HttpClient.src/M000019.html +26 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.html +294 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000001.html +26 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000002.html +18 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000003.html +26 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000004.html +18 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000005.html +32 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000006.html +18 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000007.html +20 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000008.html +20 -0
- data/doc/rdoc/classes/RFuzz/HttpEncoding.src/M000009.html +32 -0
- data/doc/rdoc/classes/RFuzz/HttpResponse.html +180 -0
- data/doc/rdoc/classes/RFuzz/Notifier.html +252 -0
- data/doc/rdoc/classes/RFuzz/Notifier.src/M000044.html +17 -0
- data/doc/rdoc/classes/RFuzz/Notifier.src/M000045.html +17 -0
- data/doc/rdoc/classes/RFuzz/Notifier.src/M000046.html +17 -0
- data/doc/rdoc/classes/RFuzz/Notifier.src/M000047.html +17 -0
- data/doc/rdoc/classes/RFuzz/Notifier.src/M000048.html +17 -0
- data/doc/rdoc/classes/RFuzz/Notifier.src/M000049.html +17 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.html +362 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000032.html +21 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000033.html +23 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000036.html +22 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000037.html +20 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000038.html +22 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000039.html +20 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000040.html +18 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000041.html +18 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000042.html +22 -0
- data/doc/rdoc/classes/RFuzz/RandomGenerator.src/M000043.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.html +383 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000056.html +19 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000057.html +23 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000058.html +26 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000059.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000060.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000061.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000062.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000063.html +19 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000064.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000065.html +23 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000066.html +18 -0
- data/doc/rdoc/classes/RFuzz/Sampler.src/M000067.html +20 -0
- data/doc/rdoc/classes/RFuzz/Session.html +415 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000020.html +31 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000021.html +18 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000022.html +18 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000023.html +34 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000024.html +19 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000025.html +19 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000026.html +26 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000027.html +29 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000028.html +19 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000029.html +18 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000030.html +18 -0
- data/doc/rdoc/classes/RFuzz/Session.src/M000031.html +23 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.html +242 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.src/M000050.html +19 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.src/M000051.html +19 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.src/M000052.html +18 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.src/M000053.html +18 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.src/M000054.html +28 -0
- data/doc/rdoc/classes/RFuzz/StatsTracker.src/M000055.html +18 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/COPYING.html +168 -0
- data/doc/rdoc/files/LICENSE.html +168 -0
- data/doc/rdoc/files/README.html +473 -0
- data/doc/rdoc/files/lib/rfuzz/client_rb.html +111 -0
- data/doc/rdoc/files/lib/rfuzz/random_rb.html +116 -0
- data/doc/rdoc/files/lib/rfuzz/rfuzz_rb.html +109 -0
- data/doc/rdoc/files/lib/rfuzz/session_rb.html +111 -0
- data/doc/rdoc/files/lib/rfuzz/stats_rb.html +113 -0
- data/doc/rdoc/fr_class_index.html +35 -0
- data/doc/rdoc/fr_file_index.html +34 -0
- data/doc/rdoc/fr_method_index.html +93 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/amazon_headers.rb +38 -0
- data/examples/hpricot_pudding.rb +22 -0
- data/examples/kill_routes.rb +26 -0
- data/examples/mongrel_test_suite/lib/gen.rb +24 -0
- data/examples/mongrel_test_suite/test/camping/static_files.rb +9 -0
- data/examples/mongrel_test_suite/test/camping/upload_file.rb +9 -0
- data/examples/mongrel_test_suite/test/camping/upload_progress.rb +9 -0
- data/examples/mongrel_test_suite/test/http/base_protocol.rb +23 -0
- data/examples/mongrel_test_suite/test/nitro/upload_file.rb +9 -0
- data/examples/mongrel_test_suite/test/nitro/upload_progress.rb +9 -0
- data/examples/mongrel_test_suite/test/rails/static_files.rb +9 -0
- data/examples/mongrel_test_suite/test/rails/upload_file.rb +9 -0
- data/examples/mongrel_test_suite/test/rails/upload_progress.rb +9 -0
- data/examples/perftest.rb +30 -0
- data/ext/fuzzrnd/ext_help.h +14 -0
- data/ext/fuzzrnd/extconf.rb +6 -0
- data/ext/fuzzrnd/fuzzrnd.c +149 -0
- data/ext/http11_client/ext_help.h +14 -0
- data/ext/http11_client/extconf.rb +6 -0
- data/ext/http11_client/http11_client.c +288 -0
- data/ext/http11_client/http11_parser.c +629 -0
- data/ext/http11_client/http11_parser.h +46 -0
- data/ext/http11_client/http11_parser.rl +169 -0
- data/lib/rfuzz/client.rb +498 -0
- data/lib/rfuzz/random.rb +110 -0
- data/lib/rfuzz/rfuzz.rb +12 -0
- data/lib/rfuzz/session.rb +154 -0
- data/lib/rfuzz/stats.rb +159 -0
- data/resources/defaults.yaml +2 -0
- data/resources/words.txt +3310 -0
- data/test/coverage/index.html +388 -0
- data/test/coverage/lib-rfuzz-client_rb.html +1127 -0
- data/test/coverage/lib-rfuzz-random_rb.html +739 -0
- data/test/coverage/lib-rfuzz-session_rb.html +783 -0
- data/test/coverage/lib-rfuzz-stats_rb.html +788 -0
- data/test/server.rb +101 -0
- data/test/test_client.rb +164 -0
- data/test/test_fuzzrnd.rb +31 -0
- data/test/test_httpparser.rb +48 -0
- data/test/test_random.rb +75 -0
- data/test/test_session.rb +33 -0
- data/test/test_stats.rb +45 -0
- data/tools/rakehelp.rb +119 -0
- metadata +201 -0
@@ -0,0 +1,288 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2005 Zed A. Shaw
|
3
|
+
* You can redistribute it and/or modify it under the same terms as Ruby.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "ruby.h"
|
7
|
+
#include "ext_help.h"
|
8
|
+
#include <assert.h>
|
9
|
+
#include <string.h>
|
10
|
+
#include "http11_parser.h"
|
11
|
+
#include <ctype.h>
|
12
|
+
|
13
|
+
static VALUE mRFuzz;
|
14
|
+
static VALUE cHttpClientParser;
|
15
|
+
static VALUE eHttpClientParserError;
|
16
|
+
|
17
|
+
#define id_reason rb_intern("@http_reason")
|
18
|
+
#define id_status rb_intern("@http_status")
|
19
|
+
#define id_version rb_intern("@http_version")
|
20
|
+
#define id_body rb_intern("@http_body")
|
21
|
+
#define id_chunk_size rb_intern("@http_chunk_size")
|
22
|
+
|
23
|
+
void client_http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen)
|
24
|
+
{
|
25
|
+
char *ch, *end;
|
26
|
+
VALUE req = (VALUE)data;
|
27
|
+
VALUE v = Qnil;
|
28
|
+
VALUE f = Qnil;
|
29
|
+
|
30
|
+
v = rb_str_new(value, vlen);
|
31
|
+
f = rb_str_new(field, flen);
|
32
|
+
|
33
|
+
/* Yes Children, rb_str_upcase_bang isn't even available as an intern.h function.
|
34
|
+
* how incredibly handy to not have that. Nope, I have to do it by hand.*/
|
35
|
+
for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
|
36
|
+
if(*ch == '-') {
|
37
|
+
*ch = '_';
|
38
|
+
} else {
|
39
|
+
*ch = toupper(*ch);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
rb_hash_aset(req, f, v);
|
44
|
+
}
|
45
|
+
|
46
|
+
void client_reason_phrase(void *data, const char *at, size_t length)
|
47
|
+
{
|
48
|
+
VALUE req = (VALUE)data;
|
49
|
+
VALUE v = Qnil;
|
50
|
+
|
51
|
+
v = rb_str_new(at, length);
|
52
|
+
|
53
|
+
rb_ivar_set(req, id_reason, v);
|
54
|
+
}
|
55
|
+
|
56
|
+
void client_status_code(void *data, const char *at, size_t length)
|
57
|
+
{
|
58
|
+
VALUE req = (VALUE)data;
|
59
|
+
VALUE v = Qnil;
|
60
|
+
|
61
|
+
v = rb_str_new(at, length);
|
62
|
+
|
63
|
+
rb_ivar_set(req, id_status, v);
|
64
|
+
}
|
65
|
+
|
66
|
+
void client_http_version(void *data, const char *at, size_t length)
|
67
|
+
{
|
68
|
+
VALUE req = (VALUE)data;
|
69
|
+
VALUE v = Qnil;
|
70
|
+
|
71
|
+
v = rb_str_new(at, length);
|
72
|
+
|
73
|
+
rb_ivar_set(req, id_version, v);
|
74
|
+
}
|
75
|
+
|
76
|
+
/** Finalizes the request header to have a bunch of stuff that's
|
77
|
+
needed. */
|
78
|
+
|
79
|
+
void client_header_done(void *data, const char *at, size_t length)
|
80
|
+
{
|
81
|
+
VALUE req = (VALUE)data;
|
82
|
+
VALUE v = Qnil;
|
83
|
+
|
84
|
+
v = rb_str_new(at, length);
|
85
|
+
rb_ivar_set(req, id_body, v);
|
86
|
+
}
|
87
|
+
|
88
|
+
void client_chunk_size(void *data, const char *at, size_t length)
|
89
|
+
{
|
90
|
+
VALUE req = (VALUE)data;
|
91
|
+
VALUE v = Qnil;
|
92
|
+
|
93
|
+
v = rb_str_new(at, length);
|
94
|
+
|
95
|
+
rb_ivar_set(req, id_chunk_size, v);
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
void HttpClientParser_free(void *data) {
|
100
|
+
TRACE();
|
101
|
+
|
102
|
+
if(data) {
|
103
|
+
free(data);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
VALUE HttpClientParser_alloc(VALUE klass)
|
109
|
+
{
|
110
|
+
VALUE obj;
|
111
|
+
httpclient_parser *hp = ALLOC_N(httpclient_parser, 1);
|
112
|
+
TRACE();
|
113
|
+
hp->http_field = client_http_field;
|
114
|
+
hp->status_code = client_status_code;
|
115
|
+
hp->reason_phrase = client_reason_phrase;
|
116
|
+
hp->http_version = client_http_version;
|
117
|
+
hp->header_done = client_header_done;
|
118
|
+
hp->chunk_size = client_chunk_size;
|
119
|
+
httpclient_parser_init(hp);
|
120
|
+
|
121
|
+
obj = Data_Wrap_Struct(klass, NULL, HttpClientParser_free, hp);
|
122
|
+
|
123
|
+
return obj;
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
/**
|
128
|
+
* call-seq:
|
129
|
+
* parser.new -> parser
|
130
|
+
*
|
131
|
+
* Creates a new parser.
|
132
|
+
*/
|
133
|
+
VALUE HttpClientParser_init(VALUE self)
|
134
|
+
{
|
135
|
+
httpclient_parser *http = NULL;
|
136
|
+
DATA_GET(self, httpclient_parser, http);
|
137
|
+
httpclient_parser_init(http);
|
138
|
+
|
139
|
+
return self;
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
/**
|
144
|
+
* call-seq:
|
145
|
+
* parser.reset -> nil
|
146
|
+
*
|
147
|
+
* Resets the parser to it's initial state so that you can reuse it
|
148
|
+
* rather than making new ones.
|
149
|
+
*/
|
150
|
+
VALUE HttpClientParser_reset(VALUE self)
|
151
|
+
{
|
152
|
+
httpclient_parser *http = NULL;
|
153
|
+
DATA_GET(self, httpclient_parser, http);
|
154
|
+
httpclient_parser_init(http);
|
155
|
+
|
156
|
+
return Qnil;
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
/**
|
161
|
+
* call-seq:
|
162
|
+
* parser.finish -> true/false
|
163
|
+
*
|
164
|
+
* Finishes a parser early which could put in a "good" or bad state.
|
165
|
+
* You should call reset after finish it or bad things will happen.
|
166
|
+
*/
|
167
|
+
VALUE HttpClientParser_finish(VALUE self)
|
168
|
+
{
|
169
|
+
httpclient_parser *http = NULL;
|
170
|
+
DATA_GET(self, httpclient_parser, http);
|
171
|
+
httpclient_parser_finish(http);
|
172
|
+
|
173
|
+
return httpclient_parser_is_finished(http) ? Qtrue : Qfalse;
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
/**
|
178
|
+
* call-seq:
|
179
|
+
* parser.execute(req_hash, data, start) -> Integer
|
180
|
+
*
|
181
|
+
* Takes a Hash and a String of data, parses the String of data filling in the Hash
|
182
|
+
* returning an Integer to indicate how much of the data has been read. No matter
|
183
|
+
* what the return value, you should call HttpClientParser#finished? and HttpClientParser#error?
|
184
|
+
* to figure out if it's done parsing or there was an error.
|
185
|
+
*
|
186
|
+
* This function now throws an exception when there is a parsing error. This makes
|
187
|
+
* the logic for working with the parser much easier. You can still test for an
|
188
|
+
* error, but now you need to wrap the parser with an exception handling block.
|
189
|
+
*
|
190
|
+
* The third argument allows for parsing a partial request and then continuing
|
191
|
+
* the parsing from that position. It needs all of the original data as well
|
192
|
+
* so you have to append to the data buffer as you read.
|
193
|
+
*/
|
194
|
+
VALUE HttpClientParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
|
195
|
+
{
|
196
|
+
httpclient_parser *http = NULL;
|
197
|
+
int from = 0;
|
198
|
+
char *dptr = NULL;
|
199
|
+
long dlen = 0;
|
200
|
+
|
201
|
+
DATA_GET(self, httpclient_parser, http);
|
202
|
+
|
203
|
+
from = FIX2INT(start);
|
204
|
+
dptr = RSTRING(data)->ptr;
|
205
|
+
dlen = RSTRING(data)->len;
|
206
|
+
|
207
|
+
if(from >= dlen) {
|
208
|
+
rb_raise(eHttpClientParserError, "Requested start is after data buffer end.");
|
209
|
+
} else {
|
210
|
+
http->data = (void *)req_hash;
|
211
|
+
httpclient_parser_execute(http, dptr, dlen, from);
|
212
|
+
|
213
|
+
if(httpclient_parser_has_error(http)) {
|
214
|
+
rb_raise(eHttpClientParserError, "Invalid HTTP format, parsing fails.");
|
215
|
+
} else {
|
216
|
+
return INT2FIX(httpclient_parser_nread(http));
|
217
|
+
}
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
/**
|
224
|
+
* call-seq:
|
225
|
+
* parser.error? -> true/false
|
226
|
+
*
|
227
|
+
* Tells you whether the parser is in an error state.
|
228
|
+
*/
|
229
|
+
VALUE HttpClientParser_has_error(VALUE self)
|
230
|
+
{
|
231
|
+
httpclient_parser *http = NULL;
|
232
|
+
DATA_GET(self, httpclient_parser, http);
|
233
|
+
|
234
|
+
return httpclient_parser_has_error(http) ? Qtrue : Qfalse;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
/**
|
239
|
+
* call-seq:
|
240
|
+
* parser.finished? -> true/false
|
241
|
+
*
|
242
|
+
* Tells you whether the parser is finished or not and in a good state.
|
243
|
+
*/
|
244
|
+
VALUE HttpClientParser_is_finished(VALUE self)
|
245
|
+
{
|
246
|
+
httpclient_parser *http = NULL;
|
247
|
+
DATA_GET(self, httpclient_parser, http);
|
248
|
+
|
249
|
+
return httpclient_parser_is_finished(http) ? Qtrue : Qfalse;
|
250
|
+
}
|
251
|
+
|
252
|
+
|
253
|
+
/**
|
254
|
+
* call-seq:
|
255
|
+
* parser.nread -> Integer
|
256
|
+
*
|
257
|
+
* Returns the amount of data processed so far during this processing cycle. It is
|
258
|
+
* set to 0 on initialize or reset calls and is incremented each time execute is called.
|
259
|
+
*/
|
260
|
+
VALUE HttpClientParser_nread(VALUE self)
|
261
|
+
{
|
262
|
+
httpclient_parser *http = NULL;
|
263
|
+
DATA_GET(self, httpclient_parser, http);
|
264
|
+
|
265
|
+
return INT2FIX(http->nread);
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
void Init_http11_client()
|
271
|
+
{
|
272
|
+
|
273
|
+
mRFuzz = rb_define_module("RFuzz");
|
274
|
+
|
275
|
+
eHttpClientParserError = rb_define_class_under(mRFuzz, "HttpClientParserError", rb_eIOError);
|
276
|
+
|
277
|
+
cHttpClientParser = rb_define_class_under(mRFuzz, "HttpClientParser", rb_cObject);
|
278
|
+
rb_define_alloc_func(cHttpClientParser, HttpClientParser_alloc);
|
279
|
+
rb_define_method(cHttpClientParser, "initialize", HttpClientParser_init,0);
|
280
|
+
rb_define_method(cHttpClientParser, "reset", HttpClientParser_reset,0);
|
281
|
+
rb_define_method(cHttpClientParser, "finish", HttpClientParser_finish,0);
|
282
|
+
rb_define_method(cHttpClientParser, "execute", HttpClientParser_execute,3);
|
283
|
+
rb_define_method(cHttpClientParser, "error?", HttpClientParser_has_error,0);
|
284
|
+
rb_define_method(cHttpClientParser, "finished?", HttpClientParser_is_finished,0);
|
285
|
+
rb_define_method(cHttpClientParser, "nread", HttpClientParser_nread,0);
|
286
|
+
}
|
287
|
+
|
288
|
+
|
@@ -0,0 +1,629 @@
|
|
1
|
+
#line 1 "ext/http11_client/http11_parser.rl"
|
2
|
+
/**
|
3
|
+
* Copyright (c) 2005 Zed A. Shaw
|
4
|
+
* You can redistribute it and/or modify it under the same terms as Ruby.
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include "http11_parser.h"
|
8
|
+
#include <stdio.h>
|
9
|
+
#include <assert.h>
|
10
|
+
#include <stdlib.h>
|
11
|
+
#include <ctype.h>
|
12
|
+
#include <string.h>
|
13
|
+
|
14
|
+
#define LEN(AT, FPC) (FPC - buffer - parser->AT)
|
15
|
+
#define MARK(M,FPC) (parser->M = (FPC) - buffer)
|
16
|
+
#define PTR_TO(F) (buffer + parser->F)
|
17
|
+
#define L(M) fprintf(stderr, "" # M "\n");
|
18
|
+
|
19
|
+
|
20
|
+
/** machine **/
|
21
|
+
#line 91 "ext/http11_client/http11_parser.rl"
|
22
|
+
|
23
|
+
|
24
|
+
/** Data **/
|
25
|
+
|
26
|
+
#line 27 "ext/http11_client/http11_parser.c"
|
27
|
+
static int httpclient_parser_start = 0;
|
28
|
+
|
29
|
+
static int httpclient_parser_first_final = 26;
|
30
|
+
|
31
|
+
static int httpclient_parser_error = 1;
|
32
|
+
|
33
|
+
#line 95 "ext/http11_client/http11_parser.rl"
|
34
|
+
|
35
|
+
int httpclient_parser_init(httpclient_parser *parser) {
|
36
|
+
int cs = 0;
|
37
|
+
|
38
|
+
#line 39 "ext/http11_client/http11_parser.c"
|
39
|
+
{
|
40
|
+
cs = httpclient_parser_start;
|
41
|
+
}
|
42
|
+
#line 99 "ext/http11_client/http11_parser.rl"
|
43
|
+
parser->cs = cs;
|
44
|
+
parser->body_start = 0;
|
45
|
+
parser->content_len = 0;
|
46
|
+
parser->mark = 0;
|
47
|
+
parser->nread = 0;
|
48
|
+
parser->field_len = 0;
|
49
|
+
parser->field_start = 0;
|
50
|
+
|
51
|
+
return(1);
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
/** exec **/
|
56
|
+
size_t httpclient_parser_execute(httpclient_parser *parser, const char *buffer, size_t len, size_t off) {
|
57
|
+
const char *p, *pe;
|
58
|
+
int cs = parser->cs;
|
59
|
+
|
60
|
+
assert(off <= len && "offset past end of buffer");
|
61
|
+
|
62
|
+
p = buffer+off;
|
63
|
+
pe = buffer+len;
|
64
|
+
|
65
|
+
assert(*pe == '\0' && "pointer does not end on NUL");
|
66
|
+
assert(pe - p == len - off && "pointers aren't same distance");
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
#line 71 "ext/http11_client/http11_parser.c"
|
71
|
+
{
|
72
|
+
p -= 1;
|
73
|
+
if ( ++p == pe )
|
74
|
+
goto _out;
|
75
|
+
switch ( cs )
|
76
|
+
{
|
77
|
+
case 0:
|
78
|
+
switch( (*p) ) {
|
79
|
+
case 13: goto st2;
|
80
|
+
case 59: goto st4;
|
81
|
+
case 72: goto tr19;
|
82
|
+
}
|
83
|
+
if ( (*p) < 65 ) {
|
84
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
85
|
+
goto tr17;
|
86
|
+
} else if ( (*p) > 70 ) {
|
87
|
+
if ( 97 <= (*p) && (*p) <= 102 )
|
88
|
+
goto tr17;
|
89
|
+
} else
|
90
|
+
goto tr17;
|
91
|
+
goto st1;
|
92
|
+
st1:
|
93
|
+
goto _out1;
|
94
|
+
tr21:
|
95
|
+
#line 33 "ext/http11_client/http11_parser.rl"
|
96
|
+
{
|
97
|
+
parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
98
|
+
}
|
99
|
+
goto st2;
|
100
|
+
tr24:
|
101
|
+
#line 49 "ext/http11_client/http11_parser.rl"
|
102
|
+
{
|
103
|
+
parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
|
104
|
+
}
|
105
|
+
goto st2;
|
106
|
+
tr27:
|
107
|
+
#line 27 "ext/http11_client/http11_parser.rl"
|
108
|
+
{
|
109
|
+
parser->field_len = LEN(field_start, p);
|
110
|
+
}
|
111
|
+
#line 31 "ext/http11_client/http11_parser.rl"
|
112
|
+
{ MARK(mark, p); }
|
113
|
+
#line 33 "ext/http11_client/http11_parser.rl"
|
114
|
+
{
|
115
|
+
parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
116
|
+
}
|
117
|
+
goto st2;
|
118
|
+
st2:
|
119
|
+
if ( ++p == pe )
|
120
|
+
goto _out2;
|
121
|
+
case 2:
|
122
|
+
#line 123 "ext/http11_client/http11_parser.c"
|
123
|
+
if ( (*p) == 10 )
|
124
|
+
goto tr32;
|
125
|
+
goto st1;
|
126
|
+
tr32:
|
127
|
+
#line 53 "ext/http11_client/http11_parser.rl"
|
128
|
+
{
|
129
|
+
parser->body_start = p - buffer + 1;
|
130
|
+
if(parser->header_done != NULL)
|
131
|
+
parser->header_done(parser->data, p + 1, pe - p - 1);
|
132
|
+
goto _out26;
|
133
|
+
}
|
134
|
+
goto st26;
|
135
|
+
st26:
|
136
|
+
if ( ++p == pe )
|
137
|
+
goto _out26;
|
138
|
+
case 26:
|
139
|
+
#line 140 "ext/http11_client/http11_parser.c"
|
140
|
+
goto st1;
|
141
|
+
tr17:
|
142
|
+
#line 23 "ext/http11_client/http11_parser.rl"
|
143
|
+
{MARK(mark, p); }
|
144
|
+
goto st3;
|
145
|
+
st3:
|
146
|
+
if ( ++p == pe )
|
147
|
+
goto _out3;
|
148
|
+
case 3:
|
149
|
+
#line 150 "ext/http11_client/http11_parser.c"
|
150
|
+
switch( (*p) ) {
|
151
|
+
case 13: goto tr24;
|
152
|
+
case 59: goto tr26;
|
153
|
+
}
|
154
|
+
if ( (*p) < 65 ) {
|
155
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
156
|
+
goto st3;
|
157
|
+
} else if ( (*p) > 70 ) {
|
158
|
+
if ( 97 <= (*p) && (*p) <= 102 )
|
159
|
+
goto st3;
|
160
|
+
} else
|
161
|
+
goto st3;
|
162
|
+
goto st1;
|
163
|
+
tr23:
|
164
|
+
#line 33 "ext/http11_client/http11_parser.rl"
|
165
|
+
{
|
166
|
+
parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
167
|
+
}
|
168
|
+
goto st4;
|
169
|
+
tr26:
|
170
|
+
#line 49 "ext/http11_client/http11_parser.rl"
|
171
|
+
{
|
172
|
+
parser->chunk_size(parser->data, PTR_TO(mark), LEN(mark, p));
|
173
|
+
}
|
174
|
+
goto st4;
|
175
|
+
tr29:
|
176
|
+
#line 27 "ext/http11_client/http11_parser.rl"
|
177
|
+
{
|
178
|
+
parser->field_len = LEN(field_start, p);
|
179
|
+
}
|
180
|
+
#line 31 "ext/http11_client/http11_parser.rl"
|
181
|
+
{ MARK(mark, p); }
|
182
|
+
#line 33 "ext/http11_client/http11_parser.rl"
|
183
|
+
{
|
184
|
+
parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
185
|
+
}
|
186
|
+
goto st4;
|
187
|
+
st4:
|
188
|
+
if ( ++p == pe )
|
189
|
+
goto _out4;
|
190
|
+
case 4:
|
191
|
+
#line 192 "ext/http11_client/http11_parser.c"
|
192
|
+
switch( (*p) ) {
|
193
|
+
case 33: goto tr9;
|
194
|
+
case 124: goto tr9;
|
195
|
+
case 126: goto tr9;
|
196
|
+
}
|
197
|
+
if ( (*p) < 45 ) {
|
198
|
+
if ( (*p) > 39 ) {
|
199
|
+
if ( 42 <= (*p) && (*p) <= 43 )
|
200
|
+
goto tr9;
|
201
|
+
} else if ( (*p) >= 35 )
|
202
|
+
goto tr9;
|
203
|
+
} else if ( (*p) > 46 ) {
|
204
|
+
if ( (*p) < 65 ) {
|
205
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
206
|
+
goto tr9;
|
207
|
+
} else if ( (*p) > 90 ) {
|
208
|
+
if ( 94 <= (*p) && (*p) <= 122 )
|
209
|
+
goto tr9;
|
210
|
+
} else
|
211
|
+
goto tr9;
|
212
|
+
} else
|
213
|
+
goto tr9;
|
214
|
+
goto st1;
|
215
|
+
tr9:
|
216
|
+
#line 25 "ext/http11_client/http11_parser.rl"
|
217
|
+
{ MARK(field_start, p); }
|
218
|
+
goto st5;
|
219
|
+
st5:
|
220
|
+
if ( ++p == pe )
|
221
|
+
goto _out5;
|
222
|
+
case 5:
|
223
|
+
#line 224 "ext/http11_client/http11_parser.c"
|
224
|
+
switch( (*p) ) {
|
225
|
+
case 13: goto tr27;
|
226
|
+
case 33: goto st5;
|
227
|
+
case 59: goto tr29;
|
228
|
+
case 61: goto tr30;
|
229
|
+
case 124: goto st5;
|
230
|
+
case 126: goto st5;
|
231
|
+
}
|
232
|
+
if ( (*p) < 45 ) {
|
233
|
+
if ( (*p) > 39 ) {
|
234
|
+
if ( 42 <= (*p) && (*p) <= 43 )
|
235
|
+
goto st5;
|
236
|
+
} else if ( (*p) >= 35 )
|
237
|
+
goto st5;
|
238
|
+
} else if ( (*p) > 46 ) {
|
239
|
+
if ( (*p) < 65 ) {
|
240
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
241
|
+
goto st5;
|
242
|
+
} else if ( (*p) > 90 ) {
|
243
|
+
if ( 94 <= (*p) && (*p) <= 122 )
|
244
|
+
goto st5;
|
245
|
+
} else
|
246
|
+
goto st5;
|
247
|
+
} else
|
248
|
+
goto st5;
|
249
|
+
goto st1;
|
250
|
+
tr30:
|
251
|
+
#line 27 "ext/http11_client/http11_parser.rl"
|
252
|
+
{
|
253
|
+
parser->field_len = LEN(field_start, p);
|
254
|
+
}
|
255
|
+
#line 31 "ext/http11_client/http11_parser.rl"
|
256
|
+
{ MARK(mark, p); }
|
257
|
+
goto st6;
|
258
|
+
st6:
|
259
|
+
if ( ++p == pe )
|
260
|
+
goto _out6;
|
261
|
+
case 6:
|
262
|
+
#line 263 "ext/http11_client/http11_parser.c"
|
263
|
+
switch( (*p) ) {
|
264
|
+
case 33: goto tr10;
|
265
|
+
case 124: goto tr10;
|
266
|
+
case 126: goto tr10;
|
267
|
+
}
|
268
|
+
if ( (*p) < 45 ) {
|
269
|
+
if ( (*p) > 39 ) {
|
270
|
+
if ( 42 <= (*p) && (*p) <= 43 )
|
271
|
+
goto tr10;
|
272
|
+
} else if ( (*p) >= 35 )
|
273
|
+
goto tr10;
|
274
|
+
} else if ( (*p) > 46 ) {
|
275
|
+
if ( (*p) < 65 ) {
|
276
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
277
|
+
goto tr10;
|
278
|
+
} else if ( (*p) > 90 ) {
|
279
|
+
if ( 94 <= (*p) && (*p) <= 122 )
|
280
|
+
goto tr10;
|
281
|
+
} else
|
282
|
+
goto tr10;
|
283
|
+
} else
|
284
|
+
goto tr10;
|
285
|
+
goto st1;
|
286
|
+
tr10:
|
287
|
+
#line 31 "ext/http11_client/http11_parser.rl"
|
288
|
+
{ MARK(mark, p); }
|
289
|
+
goto st7;
|
290
|
+
st7:
|
291
|
+
if ( ++p == pe )
|
292
|
+
goto _out7;
|
293
|
+
case 7:
|
294
|
+
#line 295 "ext/http11_client/http11_parser.c"
|
295
|
+
switch( (*p) ) {
|
296
|
+
case 13: goto tr21;
|
297
|
+
case 33: goto st7;
|
298
|
+
case 59: goto tr23;
|
299
|
+
case 124: goto st7;
|
300
|
+
case 126: goto st7;
|
301
|
+
}
|
302
|
+
if ( (*p) < 45 ) {
|
303
|
+
if ( (*p) > 39 ) {
|
304
|
+
if ( 42 <= (*p) && (*p) <= 43 )
|
305
|
+
goto st7;
|
306
|
+
} else if ( (*p) >= 35 )
|
307
|
+
goto st7;
|
308
|
+
} else if ( (*p) > 46 ) {
|
309
|
+
if ( (*p) < 65 ) {
|
310
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
311
|
+
goto st7;
|
312
|
+
} else if ( (*p) > 90 ) {
|
313
|
+
if ( 94 <= (*p) && (*p) <= 122 )
|
314
|
+
goto st7;
|
315
|
+
} else
|
316
|
+
goto st7;
|
317
|
+
} else
|
318
|
+
goto st7;
|
319
|
+
goto st1;
|
320
|
+
tr19:
|
321
|
+
#line 23 "ext/http11_client/http11_parser.rl"
|
322
|
+
{MARK(mark, p); }
|
323
|
+
goto st8;
|
324
|
+
st8:
|
325
|
+
if ( ++p == pe )
|
326
|
+
goto _out8;
|
327
|
+
case 8:
|
328
|
+
#line 329 "ext/http11_client/http11_parser.c"
|
329
|
+
if ( (*p) == 84 )
|
330
|
+
goto st9;
|
331
|
+
goto st1;
|
332
|
+
st9:
|
333
|
+
if ( ++p == pe )
|
334
|
+
goto _out9;
|
335
|
+
case 9:
|
336
|
+
if ( (*p) == 84 )
|
337
|
+
goto st10;
|
338
|
+
goto st1;
|
339
|
+
st10:
|
340
|
+
if ( ++p == pe )
|
341
|
+
goto _out10;
|
342
|
+
case 10:
|
343
|
+
if ( (*p) == 80 )
|
344
|
+
goto st11;
|
345
|
+
goto st1;
|
346
|
+
st11:
|
347
|
+
if ( ++p == pe )
|
348
|
+
goto _out11;
|
349
|
+
case 11:
|
350
|
+
if ( (*p) == 47 )
|
351
|
+
goto st12;
|
352
|
+
goto st1;
|
353
|
+
st12:
|
354
|
+
if ( ++p == pe )
|
355
|
+
goto _out12;
|
356
|
+
case 12:
|
357
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
358
|
+
goto st13;
|
359
|
+
goto st1;
|
360
|
+
st13:
|
361
|
+
if ( ++p == pe )
|
362
|
+
goto _out13;
|
363
|
+
case 13:
|
364
|
+
if ( (*p) == 46 )
|
365
|
+
goto st14;
|
366
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
367
|
+
goto st13;
|
368
|
+
goto st1;
|
369
|
+
st14:
|
370
|
+
if ( ++p == pe )
|
371
|
+
goto _out14;
|
372
|
+
case 14:
|
373
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
374
|
+
goto st15;
|
375
|
+
goto st1;
|
376
|
+
st15:
|
377
|
+
if ( ++p == pe )
|
378
|
+
goto _out15;
|
379
|
+
case 15:
|
380
|
+
if ( (*p) == 32 )
|
381
|
+
goto tr14;
|
382
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
383
|
+
goto st15;
|
384
|
+
goto st1;
|
385
|
+
tr14:
|
386
|
+
#line 45 "ext/http11_client/http11_parser.rl"
|
387
|
+
{
|
388
|
+
parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p));
|
389
|
+
}
|
390
|
+
goto st16;
|
391
|
+
st16:
|
392
|
+
if ( ++p == pe )
|
393
|
+
goto _out16;
|
394
|
+
case 16:
|
395
|
+
#line 396 "ext/http11_client/http11_parser.c"
|
396
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
397
|
+
goto tr4;
|
398
|
+
goto st1;
|
399
|
+
tr4:
|
400
|
+
#line 23 "ext/http11_client/http11_parser.rl"
|
401
|
+
{MARK(mark, p); }
|
402
|
+
goto st17;
|
403
|
+
st17:
|
404
|
+
if ( ++p == pe )
|
405
|
+
goto _out17;
|
406
|
+
case 17:
|
407
|
+
#line 408 "ext/http11_client/http11_parser.c"
|
408
|
+
if ( (*p) == 32 )
|
409
|
+
goto tr12;
|
410
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
411
|
+
goto st17;
|
412
|
+
goto st1;
|
413
|
+
tr12:
|
414
|
+
#line 41 "ext/http11_client/http11_parser.rl"
|
415
|
+
{
|
416
|
+
parser->status_code(parser->data, PTR_TO(mark), LEN(mark, p));
|
417
|
+
}
|
418
|
+
goto st18;
|
419
|
+
st18:
|
420
|
+
if ( ++p == pe )
|
421
|
+
goto _out18;
|
422
|
+
case 18:
|
423
|
+
#line 424 "ext/http11_client/http11_parser.c"
|
424
|
+
goto tr37;
|
425
|
+
tr37:
|
426
|
+
#line 23 "ext/http11_client/http11_parser.rl"
|
427
|
+
{MARK(mark, p); }
|
428
|
+
goto st19;
|
429
|
+
st19:
|
430
|
+
if ( ++p == pe )
|
431
|
+
goto _out19;
|
432
|
+
case 19:
|
433
|
+
#line 434 "ext/http11_client/http11_parser.c"
|
434
|
+
if ( (*p) == 13 )
|
435
|
+
goto tr36;
|
436
|
+
goto st19;
|
437
|
+
tr34:
|
438
|
+
#line 33 "ext/http11_client/http11_parser.rl"
|
439
|
+
{
|
440
|
+
parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
441
|
+
}
|
442
|
+
goto st20;
|
443
|
+
tr36:
|
444
|
+
#line 37 "ext/http11_client/http11_parser.rl"
|
445
|
+
{
|
446
|
+
parser->reason_phrase(parser->data, PTR_TO(mark), LEN(mark, p));
|
447
|
+
}
|
448
|
+
goto st20;
|
449
|
+
st20:
|
450
|
+
if ( ++p == pe )
|
451
|
+
goto _out20;
|
452
|
+
case 20:
|
453
|
+
#line 454 "ext/http11_client/http11_parser.c"
|
454
|
+
if ( (*p) == 10 )
|
455
|
+
goto st21;
|
456
|
+
goto st1;
|
457
|
+
st21:
|
458
|
+
if ( ++p == pe )
|
459
|
+
goto _out21;
|
460
|
+
case 21:
|
461
|
+
switch( (*p) ) {
|
462
|
+
case 13: goto st2;
|
463
|
+
case 33: goto tr20;
|
464
|
+
case 124: goto tr20;
|
465
|
+
case 126: goto tr20;
|
466
|
+
}
|
467
|
+
if ( (*p) < 45 ) {
|
468
|
+
if ( (*p) > 39 ) {
|
469
|
+
if ( 42 <= (*p) && (*p) <= 43 )
|
470
|
+
goto tr20;
|
471
|
+
} else if ( (*p) >= 35 )
|
472
|
+
goto tr20;
|
473
|
+
} else if ( (*p) > 46 ) {
|
474
|
+
if ( (*p) < 65 ) {
|
475
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
476
|
+
goto tr20;
|
477
|
+
} else if ( (*p) > 90 ) {
|
478
|
+
if ( 94 <= (*p) && (*p) <= 122 )
|
479
|
+
goto tr20;
|
480
|
+
} else
|
481
|
+
goto tr20;
|
482
|
+
} else
|
483
|
+
goto tr20;
|
484
|
+
goto st1;
|
485
|
+
tr20:
|
486
|
+
#line 25 "ext/http11_client/http11_parser.rl"
|
487
|
+
{ MARK(field_start, p); }
|
488
|
+
goto st22;
|
489
|
+
st22:
|
490
|
+
if ( ++p == pe )
|
491
|
+
goto _out22;
|
492
|
+
case 22:
|
493
|
+
#line 494 "ext/http11_client/http11_parser.c"
|
494
|
+
switch( (*p) ) {
|
495
|
+
case 33: goto st22;
|
496
|
+
case 58: goto tr8;
|
497
|
+
case 124: goto st22;
|
498
|
+
case 126: goto st22;
|
499
|
+
}
|
500
|
+
if ( (*p) < 45 ) {
|
501
|
+
if ( (*p) > 39 ) {
|
502
|
+
if ( 42 <= (*p) && (*p) <= 43 )
|
503
|
+
goto st22;
|
504
|
+
} else if ( (*p) >= 35 )
|
505
|
+
goto st22;
|
506
|
+
} else if ( (*p) > 46 ) {
|
507
|
+
if ( (*p) < 65 ) {
|
508
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
509
|
+
goto st22;
|
510
|
+
} else if ( (*p) > 90 ) {
|
511
|
+
if ( 94 <= (*p) && (*p) <= 122 )
|
512
|
+
goto st22;
|
513
|
+
} else
|
514
|
+
goto st22;
|
515
|
+
} else
|
516
|
+
goto st22;
|
517
|
+
goto st1;
|
518
|
+
tr8:
|
519
|
+
#line 27 "ext/http11_client/http11_parser.rl"
|
520
|
+
{
|
521
|
+
parser->field_len = LEN(field_start, p);
|
522
|
+
}
|
523
|
+
goto st23;
|
524
|
+
st23:
|
525
|
+
if ( ++p == pe )
|
526
|
+
goto _out23;
|
527
|
+
case 23:
|
528
|
+
#line 529 "ext/http11_client/http11_parser.c"
|
529
|
+
if ( (*p) == 32 )
|
530
|
+
goto st24;
|
531
|
+
goto st1;
|
532
|
+
st24:
|
533
|
+
if ( ++p == pe )
|
534
|
+
goto _out24;
|
535
|
+
case 24:
|
536
|
+
if ( (*p) == 13 )
|
537
|
+
goto tr34;
|
538
|
+
goto tr38;
|
539
|
+
tr38:
|
540
|
+
#line 31 "ext/http11_client/http11_parser.rl"
|
541
|
+
{ MARK(mark, p); }
|
542
|
+
goto st25;
|
543
|
+
st25:
|
544
|
+
if ( ++p == pe )
|
545
|
+
goto _out25;
|
546
|
+
case 25:
|
547
|
+
#line 548 "ext/http11_client/http11_parser.c"
|
548
|
+
if ( (*p) == 13 )
|
549
|
+
goto tr34;
|
550
|
+
goto st25;
|
551
|
+
}
|
552
|
+
_out1: cs = 1; goto _out;
|
553
|
+
_out2: cs = 2; goto _out;
|
554
|
+
_out26: cs = 26; goto _out;
|
555
|
+
_out3: cs = 3; goto _out;
|
556
|
+
_out4: cs = 4; goto _out;
|
557
|
+
_out5: cs = 5; goto _out;
|
558
|
+
_out6: cs = 6; goto _out;
|
559
|
+
_out7: cs = 7; goto _out;
|
560
|
+
_out8: cs = 8; goto _out;
|
561
|
+
_out9: cs = 9; goto _out;
|
562
|
+
_out10: cs = 10; goto _out;
|
563
|
+
_out11: cs = 11; goto _out;
|
564
|
+
_out12: cs = 12; goto _out;
|
565
|
+
_out13: cs = 13; goto _out;
|
566
|
+
_out14: cs = 14; goto _out;
|
567
|
+
_out15: cs = 15; goto _out;
|
568
|
+
_out16: cs = 16; goto _out;
|
569
|
+
_out17: cs = 17; goto _out;
|
570
|
+
_out18: cs = 18; goto _out;
|
571
|
+
_out19: cs = 19; goto _out;
|
572
|
+
_out20: cs = 20; goto _out;
|
573
|
+
_out21: cs = 21; goto _out;
|
574
|
+
_out22: cs = 22; goto _out;
|
575
|
+
_out23: cs = 23; goto _out;
|
576
|
+
_out24: cs = 24; goto _out;
|
577
|
+
_out25: cs = 25; goto _out;
|
578
|
+
|
579
|
+
_out: {}
|
580
|
+
}
|
581
|
+
#line 126 "ext/http11_client/http11_parser.rl"
|
582
|
+
|
583
|
+
parser->cs = cs;
|
584
|
+
parser->nread += p - (buffer + off);
|
585
|
+
|
586
|
+
assert(p <= pe && "buffer overflow after parsing execute");
|
587
|
+
assert(parser->nread <= len && "nread longer than length");
|
588
|
+
assert(parser->body_start <= len && "body starts after buffer end");
|
589
|
+
assert(parser->mark < len && "mark is after buffer end");
|
590
|
+
assert(parser->field_len <= len && "field has length longer than whole buffer");
|
591
|
+
assert(parser->field_start < len && "field starts after buffer end");
|
592
|
+
|
593
|
+
if(parser->body_start) {
|
594
|
+
/* final \r\n combo encountered so stop right here */
|
595
|
+
|
596
|
+
#line 597 "ext/http11_client/http11_parser.c"
|
597
|
+
#line 140 "ext/http11_client/http11_parser.rl"
|
598
|
+
parser->nread++;
|
599
|
+
}
|
600
|
+
|
601
|
+
return(parser->nread);
|
602
|
+
}
|
603
|
+
|
604
|
+
int httpclient_parser_finish(httpclient_parser *parser)
|
605
|
+
{
|
606
|
+
int cs = parser->cs;
|
607
|
+
|
608
|
+
|
609
|
+
#line 610 "ext/http11_client/http11_parser.c"
|
610
|
+
#line 151 "ext/http11_client/http11_parser.rl"
|
611
|
+
|
612
|
+
parser->cs = cs;
|
613
|
+
|
614
|
+
if (httpclient_parser_has_error(parser) ) {
|
615
|
+
return -1;
|
616
|
+
} else if (httpclient_parser_is_finished(parser) ) {
|
617
|
+
return 1;
|
618
|
+
} else {
|
619
|
+
return 0;
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
623
|
+
int httpclient_parser_has_error(httpclient_parser *parser) {
|
624
|
+
return parser->cs == httpclient_parser_error;
|
625
|
+
}
|
626
|
+
|
627
|
+
int httpclient_parser_is_finished(httpclient_parser *parser) {
|
628
|
+
return parser->cs == httpclient_parser_first_final;
|
629
|
+
}
|