http_parser.rb 0.5.1-x86-mingw32 → 0.5.2-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +16 -16
- data/LICENSE-MIT +20 -0
- data/ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java +68 -11
- data/ext/ruby_http_parser/ruby_http_parser.c +74 -6
- data/ext/ruby_http_parser/vendor/http-parser/LICENSE-MIT +1 -1
- data/ext/ruby_http_parser/vendor/http-parser/http_parser.c +52 -10
- data/ext/ruby_http_parser/vendor/http-parser/http_parser.h +3 -1
- data/ext/ruby_http_parser/vendor/http-parser/test.c +89 -3
- data/ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT +26 -1
- data/ext/ruby_http_parser/vendor/http-parser-java/README.md +23 -143
- data/ext/ruby_http_parser/vendor/http-parser-java/TODO +3 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/build.xml +74 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/ext/primitives.jar +0 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.c +115 -61
- data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.h +19 -3
- 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 +4 -2
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java +64 -52
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java +5 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java +323 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/{lolevel/Util.java → Util.java} +27 -28
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java +259 -85
- data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java +1 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java +324 -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 +51 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java +15 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java +47 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java +183 -447
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java +61 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java +2 -1
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java +26 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java +165 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java +58 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/test.c +232 -29
- data/ext/ruby_http_parser/vendor/http-parser-java/test_permutations +1 -1
- data/ext/ruby_http_parser/vendor/http-parser-java/test_unit +1 -1
- data/ext/ruby_http_parser/vendor/http-parser-java/test_utf8 +1 -0
- data/ext/ruby_http_parser/vendor/http-parser-java/tests.dumped +154 -7
- data/ext/ruby_http_parser/vendor/http-parser-java/tests.utf8 +17 -0
- data/http_parser.rb.gemspec +8 -2
- data/lib/1.8/ruby_http_parser.so +0 -0
- data/lib/1.9/ruby_http_parser.so +0 -0
- data/lib/http_parser.rb +17 -0
- data/spec/parser_spec.rb +97 -6
- data/tasks/compile.rake +3 -1
- metadata +83 -20
- data/ext/ruby_http_parser/vendor/http-parser-java/CONTRIBUTIONS +0 -4
@@ -304,12 +304,12 @@ http_major :1
|
|
304
304
|
http_minor :1
|
305
305
|
|
306
306
|
name :connect request
|
307
|
-
raw :"CONNECT
|
307
|
+
raw :"CONNECT home0.netscape.com:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\n"
|
308
308
|
type :HTTP_REQUEST
|
309
309
|
method: HTTP_CONNECT
|
310
310
|
status_code :0
|
311
311
|
request_path:
|
312
|
-
request_url :
|
312
|
+
request_url :home0.netscape.com:443
|
313
313
|
fragment :
|
314
314
|
query_string:
|
315
315
|
body :""
|
@@ -324,7 +324,7 @@ http_minor :0
|
|
324
324
|
name :report request
|
325
325
|
raw :"REPORT /test HTTP/1.1\r\n\r\n"
|
326
326
|
type :HTTP_REQUEST
|
327
|
-
method:
|
327
|
+
method: HTTP_REPORT
|
328
328
|
status_code :0
|
329
329
|
request_path:/test
|
330
330
|
request_url :/test
|
@@ -337,8 +337,108 @@ upgrade :0
|
|
337
337
|
http_major :1
|
338
338
|
http_minor :1
|
339
339
|
|
340
|
+
name :request with no http version
|
341
|
+
raw :"GET /\r\n\r\n"
|
342
|
+
type :HTTP_REQUEST
|
343
|
+
method: HTTP_GET
|
344
|
+
status_code :0
|
345
|
+
request_path:/
|
346
|
+
request_url :/
|
347
|
+
fragment :
|
348
|
+
query_string:
|
349
|
+
body :""
|
350
|
+
body_size :0
|
351
|
+
should_keep_alive :0
|
352
|
+
upgrade :0
|
353
|
+
http_major :0
|
354
|
+
http_minor :9
|
355
|
+
|
356
|
+
name :m-search request
|
357
|
+
raw :"M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nST: \"ssdp:all\"\r\n\r\n"
|
358
|
+
type :HTTP_REQUEST
|
359
|
+
method: HTTP_MSEARCH
|
360
|
+
status_code :0
|
361
|
+
request_path:*
|
362
|
+
request_url :*
|
363
|
+
fragment :
|
364
|
+
query_string:
|
365
|
+
body :""
|
366
|
+
body_size :0
|
367
|
+
header_0 :{ "HOST": "239.255.255.250:1900"}
|
368
|
+
header_1 :{ "MAN": ""ssdp:discover""}
|
369
|
+
header_2 :{ "ST": ""ssdp:all""}
|
370
|
+
should_keep_alive :1
|
371
|
+
upgrade :0
|
372
|
+
http_major :1
|
373
|
+
http_minor :1
|
374
|
+
|
375
|
+
name :utf-8 path request
|
376
|
+
raw :"GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\nHost: github.com\r\n\r\n"
|
377
|
+
type :HTTP_REQUEST
|
378
|
+
method: HTTP_GET
|
379
|
+
status_code :0
|
380
|
+
request_path:/δ¶/δt/pope
|
381
|
+
request_url :/δ¶/δt/pope?q=1#narf
|
382
|
+
fragment :narf
|
383
|
+
query_string:q=1
|
384
|
+
body :""
|
385
|
+
body_size :0
|
386
|
+
header_0 :{ "Host": "github.com"}
|
387
|
+
should_keep_alive :1
|
388
|
+
upgrade :0
|
389
|
+
http_major :1
|
390
|
+
http_minor :1
|
391
|
+
|
392
|
+
name :host terminated by a query string
|
393
|
+
raw :"GET http://hypnotoad.org?hail=all HTTP/1.1\r\n\r\n"
|
394
|
+
type :HTTP_REQUEST
|
395
|
+
method: HTTP_GET
|
396
|
+
status_code :0
|
397
|
+
request_path:
|
398
|
+
request_url :http://hypnotoad.org?hail=all
|
399
|
+
fragment :
|
400
|
+
query_string:hail=all
|
401
|
+
body :""
|
402
|
+
body_size :0
|
403
|
+
should_keep_alive :1
|
404
|
+
upgrade :0
|
405
|
+
http_major :1
|
406
|
+
http_minor :1
|
407
|
+
|
408
|
+
name :host:port terminated by a query string
|
409
|
+
raw :"GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n\r\n"
|
410
|
+
type :HTTP_REQUEST
|
411
|
+
method: HTTP_GET
|
412
|
+
status_code :0
|
413
|
+
request_path:
|
414
|
+
request_url :http://hypnotoad.org:1234?hail=all
|
415
|
+
fragment :
|
416
|
+
query_string:hail=all
|
417
|
+
body :""
|
418
|
+
body_size :0
|
419
|
+
should_keep_alive :1
|
420
|
+
upgrade :0
|
421
|
+
http_major :1
|
422
|
+
http_minor :1
|
423
|
+
|
424
|
+
name :host:port terminated by a space
|
425
|
+
raw :"GET http://hypnotoad.org:1234 HTTP/1.1\r\n\r\n"
|
426
|
+
type :HTTP_REQUEST
|
427
|
+
method: HTTP_GET
|
428
|
+
status_code :0
|
429
|
+
request_path:
|
430
|
+
request_url :http://hypnotoad.org:1234
|
431
|
+
fragment :
|
432
|
+
query_string:
|
433
|
+
body :""
|
434
|
+
body_size :0
|
435
|
+
should_keep_alive :1
|
436
|
+
upgrade :0
|
437
|
+
http_major :1
|
438
|
+
http_minor :1
|
439
|
+
|
340
440
|
name :google 301
|
341
|
-
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\nCache-Control: public, max-age=2592000\r\nServer: gws\r\nContent-Length:
|
441
|
+
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"
|
342
442
|
type :HTTP_RESPONSE
|
343
443
|
method: HTTP_DELETE
|
344
444
|
status_code :301
|
@@ -352,9 +452,10 @@ header_0 :{ "Location": "http://www.google.com/"}
|
|
352
452
|
header_1 :{ "Content-Type": "text/html; charset=UTF-8"}
|
353
453
|
header_2 :{ "Date": "Sun, 26 Apr 2009 11:11:49 GMT"}
|
354
454
|
header_3 :{ "Expires": "Tue, 26 May 2009 11:11:49 GMT"}
|
355
|
-
header_4 :{ "
|
356
|
-
header_5 :{ "
|
357
|
-
header_6 :{ "
|
455
|
+
header_4 :{ "X-$PrototypeBI-Version": "1.6.0.3"}
|
456
|
+
header_5 :{ "Cache-Control": "public, max-age=2592000"}
|
457
|
+
header_6 :{ "Server": "gws"}
|
458
|
+
header_7 :{ "Content-Length": "219 "}
|
358
459
|
should_keep_alive :1
|
359
460
|
upgrade :0
|
360
461
|
http_major :1
|
@@ -537,3 +638,49 @@ upgrade :0
|
|
537
638
|
http_major :1
|
538
639
|
http_minor :1
|
539
640
|
|
641
|
+
name :field underscore
|
642
|
+
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"
|
643
|
+
type :HTTP_RESPONSE
|
644
|
+
method: HTTP_DELETE
|
645
|
+
status_code :200
|
646
|
+
request_path:
|
647
|
+
request_url :
|
648
|
+
fragment :
|
649
|
+
query_string:
|
650
|
+
body :""
|
651
|
+
body_size :0
|
652
|
+
header_0 :{ "Date": "Tue, 28 Sep 2010 01:14:13 GMT"}
|
653
|
+
header_1 :{ "Server": "Apache"}
|
654
|
+
header_2 :{ "Cache-Control": "no-cache, must-revalidate"}
|
655
|
+
header_3 :{ "Expires": "Mon, 26 Jul 1997 05:00:00 GMT"}
|
656
|
+
header_4 :{ ".et-Cookie": "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com"}
|
657
|
+
header_5 :{ "Vary": "Accept-Encoding"}
|
658
|
+
header_6 :{ "_eep-Alive": "timeout=45"}
|
659
|
+
header_7 :{ "_onnection": "Keep-Alive"}
|
660
|
+
header_8 :{ "Transfer-Encoding": "chunked"}
|
661
|
+
header_9 :{ "Content-Type": "text/html"}
|
662
|
+
header_10 :{ "Connection": "close"}
|
663
|
+
should_keep_alive :0
|
664
|
+
upgrade :0
|
665
|
+
http_major :1
|
666
|
+
http_minor :1
|
667
|
+
|
668
|
+
name :non-ASCII in status line
|
669
|
+
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"
|
670
|
+
type :HTTP_RESPONSE
|
671
|
+
method: HTTP_DELETE
|
672
|
+
status_code :500
|
673
|
+
request_path:
|
674
|
+
request_url :
|
675
|
+
fragment :
|
676
|
+
query_string:
|
677
|
+
body :""
|
678
|
+
body_size :0
|
679
|
+
header_0 :{ "Date": "Fri, 5 Nov 2010 23:07:12 GMT+2"}
|
680
|
+
header_1 :{ "Content-Length": "0"}
|
681
|
+
header_2 :{ "Connection": "close"}
|
682
|
+
should_keep_alive :0
|
683
|
+
upgrade :0
|
684
|
+
http_major :1
|
685
|
+
http_minor :1
|
686
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name :utf-8 path request
|
2
|
+
raw :"GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\nHost: github.com\r\n\r\n"
|
3
|
+
type :HTTP_REQUEST
|
4
|
+
method: HTTP_GET
|
5
|
+
status_code :0
|
6
|
+
request_path:/δ¶/δt/pope
|
7
|
+
request_url :/δ¶/δt/pope?q=1#narf
|
8
|
+
fragment :narf
|
9
|
+
query_string:q=1
|
10
|
+
body :""
|
11
|
+
body_size :0
|
12
|
+
header_0 :{ "Host": "github.com"}
|
13
|
+
should_keep_alive :1
|
14
|
+
upgrade :0
|
15
|
+
http_major :1
|
16
|
+
http_minor :1
|
17
|
+
|
data/http_parser.rb.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "http_parser.rb"
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.2"
|
4
4
|
s.summary = "Simple callback-based HTTP request/response parser"
|
5
5
|
s.description = "Ruby bindings to http://github.com/ry/http-parser and http://github.com/a2800276/http-parser.java"
|
6
6
|
|
@@ -13,7 +13,13 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.extensions = ["ext/ruby_http_parser/extconf.rb"]
|
15
15
|
|
16
|
-
s.add_development_dependency 'rake-compiler', '>= 0.7.
|
16
|
+
s.add_development_dependency 'rake-compiler', '>= 0.7.9'
|
17
17
|
s.add_development_dependency 'rspec', '>= 2.0.1'
|
18
18
|
s.add_development_dependency 'json', '>= 1.4.6'
|
19
|
+
|
20
|
+
if RUBY_PLATFORM =~ /java/
|
21
|
+
s.add_development_dependency 'jruby-openssl'
|
22
|
+
else
|
23
|
+
s.add_development_dependency 'yajl-ruby', '>= 0.8.1'
|
24
|
+
end
|
19
25
|
end
|
data/lib/1.8/ruby_http_parser.so
CHANGED
Binary file
|
data/lib/1.9/ruby_http_parser.so
CHANGED
Binary file
|
data/lib/http_parser.rb
CHANGED
@@ -2,3 +2,20 @@ $:.unshift File.expand_path('../', __FILE__)
|
|
2
2
|
require 'ruby_http_parser'
|
3
3
|
|
4
4
|
Http = HTTP
|
5
|
+
|
6
|
+
module HTTP
|
7
|
+
class Parser
|
8
|
+
class << self
|
9
|
+
attr_reader :default_header_value_type
|
10
|
+
|
11
|
+
def default_header_value_type=(val)
|
12
|
+
if (val != :mixed && val != :strings && val != :arrays)
|
13
|
+
raise ArgumentError, "Invalid header value type"
|
14
|
+
end
|
15
|
+
@default_header_value_type = val
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
HTTP::Parser.default_header_value_type = :mixed
|
data/spec/parser_spec.rb
CHANGED
@@ -27,8 +27,37 @@ describe HTTP::Parser do
|
|
27
27
|
@parser.request_path.should be_nil
|
28
28
|
@parser.query_string.should be_nil
|
29
29
|
@parser.fragment.should be_nil
|
30
|
+
|
31
|
+
@parser.header_value_type.should == :mixed
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should allow us to set the header value type" do
|
35
|
+
[:mixed, :arrays, :strings].each do |type|
|
36
|
+
@parser.header_value_type = type
|
37
|
+
@parser.header_value_type.should == type
|
38
|
+
|
39
|
+
parser_tmp = HTTP::Parser.new(nil, type)
|
40
|
+
parser_tmp.header_value_type.should == type
|
41
|
+
end
|
30
42
|
end
|
31
43
|
|
44
|
+
it "should allow us to set the default header value type" do
|
45
|
+
[:mixed, :arrays, :strings].each do |type|
|
46
|
+
HTTP::Parser.default_header_value_type = type
|
47
|
+
|
48
|
+
parser = HTTP::Parser.new
|
49
|
+
parser.header_value_type.should == type
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should throw an Argument Error if header value type is invalid" do
|
54
|
+
proc{ @parser.header_value_type = 'bob' }.should raise_error(ArgumentError)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should throw an Argument Error if default header value type is invalid" do
|
58
|
+
proc{ HTTP::Parser.default_header_value_type = 'bob' }.should raise_error(ArgumentError)
|
59
|
+
end
|
60
|
+
|
32
61
|
it "should implement basic api" do
|
33
62
|
@parser <<
|
34
63
|
"GET /test?ok=1 HTTP/1.1\r\n" +
|
@@ -132,16 +161,57 @@ describe HTTP::Parser do
|
|
132
161
|
}
|
133
162
|
end
|
134
163
|
|
135
|
-
it "should handle multiple headers" do
|
164
|
+
it "should handle multiple headers using strings" do
|
165
|
+
@parser.header_value_type = :strings
|
166
|
+
|
136
167
|
@parser <<
|
137
168
|
"GET / HTTP/1.0\r\n" +
|
138
|
-
"
|
139
|
-
"
|
169
|
+
"Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
|
170
|
+
"Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" +
|
140
171
|
"\r\n"
|
141
172
|
|
142
|
-
@parser.headers.should ==
|
143
|
-
|
144
|
-
|
173
|
+
@parser.headers["Set-Cookie"].should == "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com, NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly"
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should handle multiple headers using strings" do
|
177
|
+
@parser.header_value_type = :arrays
|
178
|
+
|
179
|
+
@parser <<
|
180
|
+
"GET / HTTP/1.0\r\n" +
|
181
|
+
"Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
|
182
|
+
"Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" +
|
183
|
+
"\r\n"
|
184
|
+
|
185
|
+
@parser.headers["Set-Cookie"].should == [
|
186
|
+
"PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com",
|
187
|
+
"NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly"
|
188
|
+
]
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should handle multiple headers using mixed" do
|
192
|
+
@parser.header_value_type = :mixed
|
193
|
+
|
194
|
+
@parser <<
|
195
|
+
"GET / HTTP/1.0\r\n" +
|
196
|
+
"Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
|
197
|
+
"Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" +
|
198
|
+
"\r\n"
|
199
|
+
|
200
|
+
@parser.headers["Set-Cookie"].should == [
|
201
|
+
"PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com",
|
202
|
+
"NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly"
|
203
|
+
]
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should handle a single cookie using mixed" do
|
207
|
+
@parser.header_value_type = :mixed
|
208
|
+
|
209
|
+
@parser <<
|
210
|
+
"GET / HTTP/1.0\r\n" +
|
211
|
+
"Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
|
212
|
+
"\r\n"
|
213
|
+
|
214
|
+
@parser.headers["Set-Cookie"].should == "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com"
|
145
215
|
end
|
146
216
|
|
147
217
|
it "should support alternative api" do
|
@@ -172,6 +242,27 @@ describe HTTP::Parser do
|
|
172
242
|
@done.should be_true
|
173
243
|
end
|
174
244
|
|
245
|
+
it 'sets upgrade_data if available' do
|
246
|
+
@parser <<
|
247
|
+
"GET /demo HTTP/1.1\r\n" +
|
248
|
+
"Connection: Upgrade\r\n" +
|
249
|
+
"Upgrade: WebSocket\r\n\r\n" +
|
250
|
+
"third key data"
|
251
|
+
|
252
|
+
@parser.upgrade?.should be_true
|
253
|
+
@parser.upgrade_data.should == 'third key data'
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'sets upgrade_data to blank if un-available' do
|
257
|
+
@parser <<
|
258
|
+
"GET /demo HTTP/1.1\r\n" +
|
259
|
+
"Connection: Upgrade\r\n" +
|
260
|
+
"Upgrade: WebSocket\r\n\r\n"
|
261
|
+
|
262
|
+
@parser.upgrade?.should be_true
|
263
|
+
@parser.upgrade_data.should == ''
|
264
|
+
end
|
265
|
+
|
175
266
|
%w[ request response ].each do |type|
|
176
267
|
JSON.parse(File.read(File.expand_path("../support/#{type}s.json", __FILE__))).each do |test|
|
177
268
|
test['headers'] ||= {}
|
data/tasks/compile.rake
CHANGED
@@ -10,7 +10,9 @@ Rake::GemPackageTask.new(gemspec) do |pkg|
|
|
10
10
|
end
|
11
11
|
|
12
12
|
if RUBY_PLATFORM =~ /java/
|
13
|
-
Rake::JavaExtensionTask.new("ruby_http_parser", gemspec)
|
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
|
14
16
|
else
|
15
17
|
Rake::ExtensionTask.new("ruby_http_parser", gemspec) do |ext|
|
16
18
|
unless RUBY_PLATFORM =~ /mswin|mingw/
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_parser.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
5
11
|
platform: x86-mingw32
|
6
12
|
authors:
|
7
13
|
- Marc-Andre Cournoyer
|
@@ -10,39 +16,73 @@ autorequire:
|
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date: 2011-
|
19
|
+
date: 2011-08-27 00:00:00 -07:00
|
14
20
|
default_executable:
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
23
|
name: rake-compiler
|
18
|
-
|
19
|
-
|
20
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
21
27
|
requirements:
|
22
28
|
- - ">="
|
23
29
|
- !ruby/object:Gem::Version
|
24
|
-
|
25
|
-
|
30
|
+
hash: 17
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 7
|
34
|
+
- 9
|
35
|
+
version: 0.7.9
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id001
|
26
38
|
- !ruby/object:Gem::Dependency
|
27
39
|
name: rspec
|
28
|
-
|
29
|
-
|
30
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
31
43
|
requirements:
|
32
44
|
- - ">="
|
33
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 13
|
47
|
+
segments:
|
48
|
+
- 2
|
49
|
+
- 0
|
50
|
+
- 1
|
34
51
|
version: 2.0.1
|
35
|
-
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
36
54
|
- !ruby/object:Gem::Dependency
|
37
55
|
name: json
|
38
|
-
|
39
|
-
|
40
|
-
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
41
59
|
requirements:
|
42
60
|
- - ">="
|
43
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 11
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 4
|
66
|
+
- 6
|
44
67
|
version: 1.4.6
|
45
|
-
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: yajl-ruby
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 61
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
- 8
|
82
|
+
- 1
|
83
|
+
version: 0.8.1
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id004
|
46
86
|
description: Ruby bindings to http://github.com/ry/http-parser and http://github.com/a2800276/http-parser.java
|
47
87
|
email:
|
48
88
|
- macournoyer@gmail.com
|
@@ -58,6 +98,7 @@ files:
|
|
58
98
|
- .gitmodules
|
59
99
|
- Gemfile
|
60
100
|
- Gemfile.lock
|
101
|
+
- LICENSE-MIT
|
61
102
|
- README.md
|
62
103
|
- Rakefile
|
63
104
|
- bench/thin.rb
|
@@ -86,13 +127,17 @@ files:
|
|
86
127
|
- ext/ruby_http_parser/vendor/http-parser/Makefile
|
87
128
|
- ext/ruby_http_parser/vendor/http-parser/README.md
|
88
129
|
- ext/ruby_http_parser/vendor/http-parser/test.c
|
130
|
+
- ext/ruby_http_parser/vendor/http-parser-java/build.xml
|
89
131
|
- ext/ruby_http_parser/vendor/http-parser-java/compile
|
90
|
-
- ext/ruby_http_parser/vendor/http-parser-java/
|
132
|
+
- ext/ruby_http_parser/vendor/http-parser-java/ext/primitives.jar
|
91
133
|
- ext/ruby_http_parser/vendor/http-parser-java/http_parser.c
|
92
134
|
- ext/ruby_http_parser/vendor/http-parser-java/http_parser.h
|
93
135
|
- ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT
|
94
136
|
- ext/ruby_http_parser/vendor/http-parser-java/Makefile
|
95
137
|
- ext/ruby_http_parser/vendor/http-parser-java/README.md
|
138
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPCallback.java
|
139
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPDataCallback.java
|
140
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPErrorCallback.java
|
96
141
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPException.java
|
97
142
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java
|
98
143
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java
|
@@ -101,14 +146,26 @@ files:
|
|
101
146
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPErrorCallback.java
|
102
147
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java
|
103
148
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java
|
104
|
-
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/
|
149
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java
|
105
150
|
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserType.java
|
151
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/Util.java
|
152
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java
|
153
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Requests.java
|
154
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Responses.java
|
155
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java
|
156
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java
|
106
157
|
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java
|
158
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
|
107
159
|
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java
|
160
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java
|
161
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java
|
162
|
+
- ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
|
108
163
|
- ext/ruby_http_parser/vendor/http-parser-java/test.c
|
109
164
|
- ext/ruby_http_parser/vendor/http-parser-java/test_permutations
|
110
165
|
- ext/ruby_http_parser/vendor/http-parser-java/test_unit
|
166
|
+
- ext/ruby_http_parser/vendor/http-parser-java/test_utf8
|
111
167
|
- ext/ruby_http_parser/vendor/http-parser-java/tests.dumped
|
168
|
+
- ext/ruby_http_parser/vendor/http-parser-java/tests.utf8
|
112
169
|
- ext/ruby_http_parser/vendor/http-parser-java/TODO
|
113
170
|
- ext/ruby_http_parser/vendor/http-parser-java/tools/byte_constants.rb
|
114
171
|
- ext/ruby_http_parser/vendor/http-parser-java/tools/const_char.rb
|
@@ -127,21 +184,27 @@ rdoc_options: []
|
|
127
184
|
require_paths:
|
128
185
|
- lib
|
129
186
|
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
130
188
|
requirements:
|
131
189
|
- - ">="
|
132
190
|
- !ruby/object:Gem::Version
|
191
|
+
hash: 3
|
192
|
+
segments:
|
193
|
+
- 0
|
133
194
|
version: "0"
|
134
|
-
version:
|
135
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
136
197
|
requirements:
|
137
198
|
- - ">="
|
138
199
|
- !ruby/object:Gem::Version
|
200
|
+
hash: 3
|
201
|
+
segments:
|
202
|
+
- 0
|
139
203
|
version: "0"
|
140
|
-
version:
|
141
204
|
requirements: []
|
142
205
|
|
143
206
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.
|
207
|
+
rubygems_version: 1.6.2
|
145
208
|
signing_key:
|
146
209
|
specification_version: 3
|
147
210
|
summary: Simple callback-based HTTP request/response parser
|