midori_http_parser 0.6.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.gitmodules +6 -0
- data/.travis.yml +33 -0
- data/Gemfile +2 -0
- data/LICENSE-MIT +20 -0
- data/README.md +90 -0
- data/Rakefile +6 -0
- data/bench/standalone.rb +23 -0
- data/bench/thin.rb +58 -0
- data/ext/ruby_http_parser/.gitignore +1 -0
- data/ext/ruby_http_parser/RubyHttpParserService.java +18 -0
- data/ext/ruby_http_parser/ext_help.h +18 -0
- data/ext/ruby_http_parser/extconf.rb +24 -0
- data/ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java +495 -0
- data/ext/ruby_http_parser/ruby_http_parser.c +516 -0
- data/ext/ruby_http_parser/vendor/.gitkeep +0 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/AUTHORS +32 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT +48 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/README.md +183 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/TODO +28 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/build.xml +74 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.c +2175 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.gyp +79 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.h +304 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/Http-parser.java.iml +22 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/FieldData.java +41 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPCallback.java +8 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPDataCallback.java +34 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPErrorCallback.java +12 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPException.java +9 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java +113 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java +36 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParserUrl.java +76 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java +256 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserType.java +13 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/Util.java +111 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPCallback.java +5 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPDataCallback.java +25 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPErrorCallback.java +7 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java +2171 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java +83 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java +374 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/ParseUrl.java +51 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Requests.java +69 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Responses.java +52 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java +16 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java +48 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java +212 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java +62 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java +117 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java +27 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Url.java +127 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java +236 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java +59 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/test.c +3425 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tests.dumped +845 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tests.utf8 +17 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tools/byte_constants.rb +6 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tools/const_char.rb +13 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tools/lowcase.rb +15 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tools/parse_tests.rb +33 -0
- data/ext/ruby_http_parser/vendor/http-parser/AUTHORS +68 -0
- data/ext/ruby_http_parser/vendor/http-parser/LICENSE-MIT +23 -0
- data/ext/ruby_http_parser/vendor/http-parser/README.md +246 -0
- data/ext/ruby_http_parser/vendor/http-parser/bench.c +111 -0
- data/ext/ruby_http_parser/vendor/http-parser/contrib/parsertrace.c +160 -0
- data/ext/ruby_http_parser/vendor/http-parser/contrib/url_parser.c +47 -0
- data/ext/ruby_http_parser/vendor/http-parser/http_parser.c +2470 -0
- data/ext/ruby_http_parser/vendor/http-parser/http_parser.gyp +111 -0
- data/ext/ruby_http_parser/vendor/http-parser/http_parser.h +432 -0
- data/ext/ruby_http_parser/vendor/http-parser/test.c +4226 -0
- data/ext/ruby_http_parser/vendor/http-parser/test_fast +0 -0
- data/ext/ruby_http_parser/vendor/http-parser/test_g +0 -0
- data/lib/http/parser.rb +1 -0
- data/lib/http_parser.rb +21 -0
- data/midori_http_parser.gemspec +24 -0
- data/spec/parser_spec.rb +376 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/requests.json +631 -0
- data/spec/support/responses.json +375 -0
- data/tasks/compile.rake +42 -0
- data/tasks/fixtures.rake +71 -0
- data/tasks/spec.rake +5 -0
- data/tasks/submodules.rake +7 -0
- metadata +206 -0
@@ -0,0 +1,375 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "google 301",
|
4
|
+
"type": "HTTP_RESPONSE",
|
5
|
+
"raw": "HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.google.com/\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Sun, 26 Apr 2009 11:11:49 GMT\r\nExpires: Tue, 26 May 2009 11:11:49 GMT\r\nX-$PrototypeBI-Version: 1.6.0.3\r\nCache-Control: public, max-age=2592000\r\nServer: gws\r\nContent-Length: 219 \r\n\r\n<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>301 Moved</TITLE></HEAD><BODY>\n<H1>301 Moved</H1>\nThe document has moved\n<A HREF=\"http://www.google.com/\">here</A>.\r\n</BODY></HTML>\r\n",
|
6
|
+
"should_keep_alive": true,
|
7
|
+
"message_complete_on_eof": false,
|
8
|
+
"http_major": 1,
|
9
|
+
"http_minor": 1,
|
10
|
+
"status_code": 301,
|
11
|
+
"num_headers": 8,
|
12
|
+
"headers": {
|
13
|
+
"Location": "http://www.google.com/",
|
14
|
+
"Content-Type": "text/html; charset=UTF-8",
|
15
|
+
"Date": "Sun, 26 Apr 2009 11:11:49 GMT",
|
16
|
+
"Expires": "Tue, 26 May 2009 11:11:49 GMT",
|
17
|
+
"X-$PrototypeBI-Version": "1.6.0.3",
|
18
|
+
"Cache-Control": "public, max-age=2592000",
|
19
|
+
"Server": "gws",
|
20
|
+
"Content-Length": "219 "
|
21
|
+
},
|
22
|
+
"body": "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>301 Moved</TITLE></HEAD><BODY>\n<H1>301 Moved</H1>\nThe document has moved\n<A HREF=\"http://www.google.com/\">here</A>.\r\n</BODY></HTML>\r\n",
|
23
|
+
"strict": true
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"name": "no content-length response",
|
27
|
+
"type": "HTTP_RESPONSE",
|
28
|
+
"raw": "HTTP/1.1 200 OK\r\nDate: Tue, 04 Aug 2009 07:59:32 GMT\r\nServer: Apache\r\nX-Powered-By: Servlet/2.5 JSP/2.1\r\nContent-Type: text/xml; charset=utf-8\r\nConnection: close\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <SOAP-ENV:Body>\n <SOAP-ENV:Fault>\n <faultcode>SOAP-ENV:Client</faultcode>\n <faultstring>Client Error</faultstring>\n </SOAP-ENV:Fault>\n </SOAP-ENV:Body>\n</SOAP-ENV:Envelope>",
|
29
|
+
"should_keep_alive": false,
|
30
|
+
"message_complete_on_eof": true,
|
31
|
+
"http_major": 1,
|
32
|
+
"http_minor": 1,
|
33
|
+
"status_code": 200,
|
34
|
+
"num_headers": 5,
|
35
|
+
"headers": {
|
36
|
+
"Date": "Tue, 04 Aug 2009 07:59:32 GMT",
|
37
|
+
"Server": "Apache",
|
38
|
+
"X-Powered-By": "Servlet/2.5 JSP/2.1",
|
39
|
+
"Content-Type": "text/xml; charset=utf-8",
|
40
|
+
"Connection": "close"
|
41
|
+
},
|
42
|
+
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <SOAP-ENV:Body>\n <SOAP-ENV:Fault>\n <faultcode>SOAP-ENV:Client</faultcode>\n <faultstring>Client Error</faultstring>\n </SOAP-ENV:Fault>\n </SOAP-ENV:Body>\n</SOAP-ENV:Envelope>",
|
43
|
+
"strict": true
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "404 no headers no body",
|
47
|
+
"type": "HTTP_RESPONSE",
|
48
|
+
"raw": "HTTP/1.1 404 Not Found\r\n\r\n",
|
49
|
+
"should_keep_alive": false,
|
50
|
+
"message_complete_on_eof": true,
|
51
|
+
"http_major": 1,
|
52
|
+
"http_minor": 1,
|
53
|
+
"status_code": 404,
|
54
|
+
"num_headers": 0,
|
55
|
+
"headers": {
|
56
|
+
|
57
|
+
},
|
58
|
+
"body_size": 0,
|
59
|
+
"body": "",
|
60
|
+
"strict": true
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"name": "301 no response phrase",
|
64
|
+
"type": "HTTP_RESPONSE",
|
65
|
+
"raw": "HTTP/1.1 301\r\n\r\n",
|
66
|
+
"should_keep_alive": false,
|
67
|
+
"message_complete_on_eof": true,
|
68
|
+
"http_major": 1,
|
69
|
+
"http_minor": 1,
|
70
|
+
"status_code": 301,
|
71
|
+
"num_headers": 0,
|
72
|
+
"headers": {
|
73
|
+
|
74
|
+
},
|
75
|
+
"body": "",
|
76
|
+
"strict": true
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"name": "200 trailing space on chunked body",
|
80
|
+
"type": "HTTP_RESPONSE",
|
81
|
+
"raw": "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n25 \r\nThis is the data in the first chunk\r\n\r\n1C\r\nand this is the second one\r\n\r\n0 \r\n\r\n",
|
82
|
+
"should_keep_alive": true,
|
83
|
+
"message_complete_on_eof": false,
|
84
|
+
"http_major": 1,
|
85
|
+
"http_minor": 1,
|
86
|
+
"status_code": 200,
|
87
|
+
"num_headers": 2,
|
88
|
+
"headers": {
|
89
|
+
"Content-Type": "text/plain",
|
90
|
+
"Transfer-Encoding": "chunked"
|
91
|
+
},
|
92
|
+
"body_size": 65,
|
93
|
+
"body": "This is the data in the first chunk\r\nand this is the second one\r\n",
|
94
|
+
"strict": true
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"name": "no carriage ret",
|
98
|
+
"type": "HTTP_RESPONSE",
|
99
|
+
"raw": "HTTP/1.1 200 OK\nContent-Type: text/html; charset=utf-8\nConnection: close\n\nthese headers are from http://news.ycombinator.com/",
|
100
|
+
"should_keep_alive": false,
|
101
|
+
"message_complete_on_eof": true,
|
102
|
+
"http_major": 1,
|
103
|
+
"http_minor": 1,
|
104
|
+
"status_code": 200,
|
105
|
+
"num_headers": 2,
|
106
|
+
"headers": {
|
107
|
+
"Content-Type": "text/html; charset=utf-8",
|
108
|
+
"Connection": "close"
|
109
|
+
},
|
110
|
+
"body": "these headers are from http://news.ycombinator.com/",
|
111
|
+
"strict": true
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"name": "proxy connection",
|
115
|
+
"type": "HTTP_RESPONSE",
|
116
|
+
"raw": "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 11\r\nProxy-Connection: close\r\nDate: Thu, 31 Dec 2009 20:55:48 +0000\r\n\r\nhello world",
|
117
|
+
"should_keep_alive": false,
|
118
|
+
"message_complete_on_eof": false,
|
119
|
+
"http_major": 1,
|
120
|
+
"http_minor": 1,
|
121
|
+
"status_code": 200,
|
122
|
+
"num_headers": 4,
|
123
|
+
"headers": {
|
124
|
+
"Content-Type": "text/html; charset=UTF-8",
|
125
|
+
"Content-Length": "11",
|
126
|
+
"Proxy-Connection": "close",
|
127
|
+
"Date": "Thu, 31 Dec 2009 20:55:48 +0000"
|
128
|
+
},
|
129
|
+
"body": "hello world",
|
130
|
+
"strict": true
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"name": "underscore header key",
|
134
|
+
"type": "HTTP_RESPONSE",
|
135
|
+
"raw": "HTTP/1.1 200 OK\r\nServer: DCLK-AdSvr\r\nContent-Type: text/xml\r\nContent-Length: 0\r\nDCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n",
|
136
|
+
"should_keep_alive": true,
|
137
|
+
"message_complete_on_eof": false,
|
138
|
+
"http_major": 1,
|
139
|
+
"http_minor": 1,
|
140
|
+
"status_code": 200,
|
141
|
+
"num_headers": 4,
|
142
|
+
"headers": {
|
143
|
+
"Server": "DCLK-AdSvr",
|
144
|
+
"Content-Type": "text/xml",
|
145
|
+
"Content-Length": "0",
|
146
|
+
"DCLK_imp": "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o"
|
147
|
+
},
|
148
|
+
"body": "",
|
149
|
+
"strict": true
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"name": "bonjourmadame.fr",
|
153
|
+
"type": "HTTP_RESPONSE",
|
154
|
+
"raw": "HTTP/1.0 301 Moved Permanently\r\nDate: Thu, 03 Jun 2010 09:56:32 GMT\r\nServer: Apache/2.2.3 (Red Hat)\r\nCache-Control: public\r\nPragma: \r\nLocation: http://www.bonjourmadame.fr/\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: keep-alive\r\n\r\n",
|
155
|
+
"should_keep_alive": true,
|
156
|
+
"message_complete_on_eof": false,
|
157
|
+
"http_major": 1,
|
158
|
+
"http_minor": 0,
|
159
|
+
"status_code": 301,
|
160
|
+
"num_headers": 9,
|
161
|
+
"headers": {
|
162
|
+
"Date": "Thu, 03 Jun 2010 09:56:32 GMT",
|
163
|
+
"Server": "Apache/2.2.3 (Red Hat)",
|
164
|
+
"Cache-Control": "public",
|
165
|
+
"Pragma": "",
|
166
|
+
"Location": "http://www.bonjourmadame.fr/",
|
167
|
+
"Vary": "Accept-Encoding",
|
168
|
+
"Content-Length": "0",
|
169
|
+
"Content-Type": "text/html; charset=UTF-8",
|
170
|
+
"Connection": "keep-alive"
|
171
|
+
},
|
172
|
+
"body": "",
|
173
|
+
"strict": true
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"name": "field underscore",
|
177
|
+
"type": "HTTP_RESPONSE",
|
178
|
+
"raw": "HTTP/1.1 200 OK\r\nDate: Tue, 28 Sep 2010 01:14:13 GMT\r\nServer: Apache\r\nCache-Control: no-cache, must-revalidate\r\nExpires: Mon, 26 Jul 1997 05:00:00 GMT\r\n.et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\nVary: Accept-Encoding\r\n_eep-Alive: timeout=45\r\n_onnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n0\r\n\r\n",
|
179
|
+
"should_keep_alive": false,
|
180
|
+
"message_complete_on_eof": false,
|
181
|
+
"http_major": 1,
|
182
|
+
"http_minor": 1,
|
183
|
+
"status_code": 200,
|
184
|
+
"num_headers": 11,
|
185
|
+
"headers": {
|
186
|
+
"Date": "Tue, 28 Sep 2010 01:14:13 GMT",
|
187
|
+
"Server": "Apache",
|
188
|
+
"Cache-Control": "no-cache, must-revalidate",
|
189
|
+
"Expires": "Mon, 26 Jul 1997 05:00:00 GMT",
|
190
|
+
".et-Cookie": "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com",
|
191
|
+
"Vary": "Accept-Encoding",
|
192
|
+
"_eep-Alive": "timeout=45",
|
193
|
+
"_onnection": "Keep-Alive",
|
194
|
+
"Transfer-Encoding": "chunked",
|
195
|
+
"Content-Type": "text/html",
|
196
|
+
"Connection": "close"
|
197
|
+
},
|
198
|
+
"body": "",
|
199
|
+
"strict": true
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"name": "non-ASCII in status line",
|
203
|
+
"type": "HTTP_RESPONSE",
|
204
|
+
"raw": "HTTP/1.1 500 Oriëntatieprobleem\r\nDate: Fri, 5 Nov 2010 23:07:12 GMT+2\r\nContent-Length: 0\r\nConnection: close\r\n\r\n",
|
205
|
+
"should_keep_alive": false,
|
206
|
+
"message_complete_on_eof": false,
|
207
|
+
"http_major": 1,
|
208
|
+
"http_minor": 1,
|
209
|
+
"status_code": 500,
|
210
|
+
"num_headers": 3,
|
211
|
+
"headers": {
|
212
|
+
"Date": "Fri, 5 Nov 2010 23:07:12 GMT+2",
|
213
|
+
"Content-Length": "0",
|
214
|
+
"Connection": "close"
|
215
|
+
},
|
216
|
+
"body": "",
|
217
|
+
"strict": true
|
218
|
+
},
|
219
|
+
{
|
220
|
+
"name": "http version 0.9",
|
221
|
+
"type": "HTTP_RESPONSE",
|
222
|
+
"raw": "HTTP/0.9 200 OK\r\n\r\n",
|
223
|
+
"should_keep_alive": false,
|
224
|
+
"message_complete_on_eof": true,
|
225
|
+
"http_major": 0,
|
226
|
+
"http_minor": 9,
|
227
|
+
"status_code": 200,
|
228
|
+
"num_headers": 0,
|
229
|
+
"headers": {
|
230
|
+
|
231
|
+
},
|
232
|
+
"body": "",
|
233
|
+
"strict": true
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"name": "neither content-length nor transfer-encoding response",
|
237
|
+
"type": "HTTP_RESPONSE",
|
238
|
+
"raw": "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello world",
|
239
|
+
"should_keep_alive": false,
|
240
|
+
"message_complete_on_eof": true,
|
241
|
+
"http_major": 1,
|
242
|
+
"http_minor": 1,
|
243
|
+
"status_code": 200,
|
244
|
+
"num_headers": 1,
|
245
|
+
"headers": {
|
246
|
+
"Content-Type": "text/plain"
|
247
|
+
},
|
248
|
+
"body": "hello world",
|
249
|
+
"strict": true
|
250
|
+
},
|
251
|
+
{
|
252
|
+
"name": "HTTP/1.0 with keep-alive and EOF-terminated 200 status",
|
253
|
+
"type": "HTTP_RESPONSE",
|
254
|
+
"raw": "HTTP/1.0 200 OK\r\nConnection: keep-alive\r\n\r\n",
|
255
|
+
"should_keep_alive": false,
|
256
|
+
"message_complete_on_eof": true,
|
257
|
+
"http_major": 1,
|
258
|
+
"http_minor": 0,
|
259
|
+
"status_code": 200,
|
260
|
+
"num_headers": 1,
|
261
|
+
"headers": {
|
262
|
+
"Connection": "keep-alive"
|
263
|
+
},
|
264
|
+
"body_size": 0,
|
265
|
+
"body": "",
|
266
|
+
"strict": true
|
267
|
+
},
|
268
|
+
{
|
269
|
+
"name": "HTTP/1.0 with keep-alive and a 204 status",
|
270
|
+
"type": "HTTP_RESPONSE",
|
271
|
+
"raw": "HTTP/1.0 204 No content\r\nConnection: keep-alive\r\n\r\n",
|
272
|
+
"should_keep_alive": true,
|
273
|
+
"message_complete_on_eof": false,
|
274
|
+
"http_major": 1,
|
275
|
+
"http_minor": 0,
|
276
|
+
"status_code": 204,
|
277
|
+
"num_headers": 1,
|
278
|
+
"headers": {
|
279
|
+
"Connection": "keep-alive"
|
280
|
+
},
|
281
|
+
"body_size": 0,
|
282
|
+
"body": "",
|
283
|
+
"strict": true
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"name": "HTTP/1.1 with an EOF-terminated 200 status",
|
287
|
+
"type": "HTTP_RESPONSE",
|
288
|
+
"raw": "HTTP/1.1 200 OK\r\n\r\n",
|
289
|
+
"should_keep_alive": false,
|
290
|
+
"message_complete_on_eof": true,
|
291
|
+
"http_major": 1,
|
292
|
+
"http_minor": 1,
|
293
|
+
"status_code": 200,
|
294
|
+
"num_headers": 0,
|
295
|
+
"headers": {
|
296
|
+
|
297
|
+
},
|
298
|
+
"body_size": 0,
|
299
|
+
"body": "",
|
300
|
+
"strict": true
|
301
|
+
},
|
302
|
+
{
|
303
|
+
"name": "HTTP/1.1 with a 204 status",
|
304
|
+
"type": "HTTP_RESPONSE",
|
305
|
+
"raw": "HTTP/1.1 204 No content\r\n\r\n",
|
306
|
+
"should_keep_alive": true,
|
307
|
+
"message_complete_on_eof": false,
|
308
|
+
"http_major": 1,
|
309
|
+
"http_minor": 1,
|
310
|
+
"status_code": 204,
|
311
|
+
"num_headers": 0,
|
312
|
+
"headers": {
|
313
|
+
|
314
|
+
},
|
315
|
+
"body_size": 0,
|
316
|
+
"body": "",
|
317
|
+
"strict": true
|
318
|
+
},
|
319
|
+
{
|
320
|
+
"name": "HTTP/1.1 with a 204 status and keep-alive disabled",
|
321
|
+
"type": "HTTP_RESPONSE",
|
322
|
+
"raw": "HTTP/1.1 204 No content\r\nConnection: close\r\n\r\n",
|
323
|
+
"should_keep_alive": false,
|
324
|
+
"message_complete_on_eof": false,
|
325
|
+
"http_major": 1,
|
326
|
+
"http_minor": 1,
|
327
|
+
"status_code": 204,
|
328
|
+
"num_headers": 1,
|
329
|
+
"headers": {
|
330
|
+
"Connection": "close"
|
331
|
+
},
|
332
|
+
"body_size": 0,
|
333
|
+
"body": "",
|
334
|
+
"strict": true
|
335
|
+
},
|
336
|
+
{
|
337
|
+
"name": "HTTP/1.1 with chunked endocing and a 200 response",
|
338
|
+
"type": "HTTP_RESPONSE",
|
339
|
+
"raw": "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n",
|
340
|
+
"should_keep_alive": true,
|
341
|
+
"message_complete_on_eof": false,
|
342
|
+
"http_major": 1,
|
343
|
+
"http_minor": 1,
|
344
|
+
"status_code": 200,
|
345
|
+
"num_headers": 1,
|
346
|
+
"headers": {
|
347
|
+
"Transfer-Encoding": "chunked"
|
348
|
+
},
|
349
|
+
"body_size": 0,
|
350
|
+
"body": "",
|
351
|
+
"strict": true
|
352
|
+
},
|
353
|
+
{
|
354
|
+
"name": "field space",
|
355
|
+
"type": "HTTP_RESPONSE",
|
356
|
+
"strict": false,
|
357
|
+
"raw": "HTTP/1.1 200 OK\r\nServer: Microsoft-IIS/6.0\r\nX-Powered-By: ASP.NET\r\nen-US Content-Type: text/xml\r\nContent-Type: text/xml\r\nContent-Length: 16\r\nDate: Fri, 23 Jul 2010 18:45:38 GMT\r\nConnection: keep-alive\r\n\r\n<xml>hello</xml>",
|
358
|
+
"should_keep_alive": true,
|
359
|
+
"message_complete_on_eof": false,
|
360
|
+
"http_major": 1,
|
361
|
+
"http_minor": 1,
|
362
|
+
"status_code": 200,
|
363
|
+
"num_headers": 7,
|
364
|
+
"headers": {
|
365
|
+
"Server": "Microsoft-IIS/6.0",
|
366
|
+
"X-Powered-By": "ASP.NET",
|
367
|
+
"en-US Content-Type": "text/xml",
|
368
|
+
"Content-Type": "text/xml",
|
369
|
+
"Content-Length": "16",
|
370
|
+
"Date": "Fri, 23 Jul 2010 18:45:38 GMT",
|
371
|
+
"Connection": "keep-alive"
|
372
|
+
},
|
373
|
+
"body": "<xml>hello</xml>"
|
374
|
+
}
|
375
|
+
]
|
data/tasks/compile.rake
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems/package_task'
|
2
|
+
require 'rake/extensiontask'
|
3
|
+
require 'rake/javaextensiontask'
|
4
|
+
|
5
|
+
def gemspec
|
6
|
+
@clean_gemspec ||= eval(File.read(File.expand_path('../../midori_http_parser.gemspec', __FILE__)))
|
7
|
+
end
|
8
|
+
|
9
|
+
Gem::PackageTask.new(gemspec) do |pkg|
|
10
|
+
end
|
11
|
+
|
12
|
+
if RUBY_PLATFORM =~ /java/
|
13
|
+
Rake::JavaExtensionTask.new("ruby_http_parser", gemspec) do |ext|
|
14
|
+
ext.classpath = File.expand_path('../../ext/ruby_http_parser/vendor/http-parser-java/ext/primitives.jar', __FILE__)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
Rake::ExtensionTask.new("ruby_http_parser", gemspec) do |ext|
|
18
|
+
unless RUBY_PLATFORM =~ /mswin|mingw/
|
19
|
+
ext.cross_compile = true
|
20
|
+
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
21
|
+
|
22
|
+
# inject 1.8/1.9 pure-ruby entry point
|
23
|
+
ext.cross_compiling do |spec|
|
24
|
+
spec.files += ['lib/ruby_http_parser.rb']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
file 'lib/ruby_http_parser.rb' do |t|
|
31
|
+
File.open(t.name, 'wb') do |f|
|
32
|
+
f.write <<-eoruby
|
33
|
+
RUBY_VERSION =~ /(\\d+.\\d+)/
|
34
|
+
require "\#{$1}/ruby_http_parser"
|
35
|
+
eoruby
|
36
|
+
end
|
37
|
+
at_exit{ FileUtils.rm t.name if File.exists?(t.name) }
|
38
|
+
end
|
39
|
+
|
40
|
+
if Rake::Task.task_defined?(:cross)
|
41
|
+
task :cross => 'lib/ruby_http_parser.rb'
|
42
|
+
end
|
data/tasks/fixtures.rake
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
desc "Generate test fixtures"
|
2
|
+
task :fixtures => :submodules do
|
3
|
+
require 'yajl'
|
4
|
+
data = File.read File.expand_path('../../ext/ruby_http_parser/vendor/http-parser/test.c', __FILE__)
|
5
|
+
|
6
|
+
%w[ requests responses ].each do |type|
|
7
|
+
# find test definitions in between requests/responses[]= and .name=NULL
|
8
|
+
tmp = data[/#{type}\[\]\s*=(.+?),\s*\{\s*\.name=\s*NULL/m, 1]
|
9
|
+
|
10
|
+
# replace first { with a [ (parsing an array of test cases)
|
11
|
+
tmp.sub!('{','[')
|
12
|
+
|
13
|
+
# replace booleans
|
14
|
+
tmp.gsub!('TRUE', 'true')
|
15
|
+
tmp.gsub!('FALSE', 'false')
|
16
|
+
|
17
|
+
# mark strict mode tests
|
18
|
+
tmp.gsub!(%r|#if\s+!HTTP_PARSER_STRICT(.+?)#endif\s*/\*\s*!HTTP_PARSER_STRICT.+\n|m){
|
19
|
+
$1.gsub(/^(.+,\.type= .+)$/, "\\1\n, .strict= false")
|
20
|
+
}
|
21
|
+
|
22
|
+
# remove macros and comments
|
23
|
+
tmp.gsub!(/^#(if|elif|endif|define).+$/,'')
|
24
|
+
tmp.gsub!(/\/\*(.+?)\*\/$/,'')
|
25
|
+
|
26
|
+
# HTTP_* enums become strings
|
27
|
+
tmp.gsub!(/(= )(HTTP_\w+)/){
|
28
|
+
"#{$1}#{$2.sub('MSEARCH','M-SEARCH').dump}"
|
29
|
+
}
|
30
|
+
|
31
|
+
# join multiline strings for body and raw data
|
32
|
+
tmp.gsub!(/((body|raw)\s*=)(.+?)(\n\s+[\},])/m){
|
33
|
+
before, after = $1, $4
|
34
|
+
raw = $3.split("\n").map{ |l| l.strip[1..-2] }.join('')
|
35
|
+
"#{before} \"#{raw}\" #{after}"
|
36
|
+
}
|
37
|
+
|
38
|
+
# make headers an array of array tuples
|
39
|
+
tmp.gsub!(/(\.headers\s*=)(.+?)(\s*,\.)/m){
|
40
|
+
before, after = $1, $3
|
41
|
+
raw = $2.gsub('{', '[').gsub('}', ']')
|
42
|
+
"#{before} #{raw} #{after}"
|
43
|
+
}
|
44
|
+
|
45
|
+
# .name= becomes "name":
|
46
|
+
tmp.gsub!(/^(.{2,5})\.(\w+)\s*=/){
|
47
|
+
"#{$1}#{$2.dump}: "
|
48
|
+
}
|
49
|
+
|
50
|
+
# evaluate addition expressions
|
51
|
+
tmp.gsub!(/(body_size\":\s*)(\d+)\+(\d+)/){
|
52
|
+
"#{$1}#{$2.to_i+$3.to_i}"
|
53
|
+
}
|
54
|
+
|
55
|
+
# end result array
|
56
|
+
tmp << ']'
|
57
|
+
|
58
|
+
# normalize data
|
59
|
+
results = Yajl.load(tmp, :symbolize_keys => true)
|
60
|
+
results.map{ |res|
|
61
|
+
res[:headers] and res[:headers] = Hash[*res[:headers].flatten]
|
62
|
+
res[:method] and res[:method].gsub!(/^HTTP_/, '')
|
63
|
+
res[:strict] = true unless res.has_key?(:strict)
|
64
|
+
}
|
65
|
+
|
66
|
+
# write to a file
|
67
|
+
File.open("spec/support/#{type}.json", 'w'){ |f|
|
68
|
+
f.write Yajl.dump(results, :pretty => true)
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|