http_parser.rb 0.5.1 → 0.5.3

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.
Files changed (51) hide show
  1. data/.gitmodules +1 -1
  2. data/Gemfile.lock +6 -6
  3. data/LICENSE-MIT +20 -0
  4. data/README.md +1 -1
  5. data/ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java +68 -11
  6. data/ext/ruby_http_parser/ruby_http_parser.c +80 -8
  7. data/ext/ruby_http_parser/vendor/http-parser/LICENSE-MIT +1 -1
  8. data/ext/ruby_http_parser/vendor/http-parser/http_parser.c +52 -10
  9. data/ext/ruby_http_parser/vendor/http-parser/http_parser.h +3 -1
  10. data/ext/ruby_http_parser/vendor/http-parser/test.c +89 -3
  11. data/ext/ruby_http_parser/vendor/http-parser-java/LICENSE-MIT +26 -1
  12. data/ext/ruby_http_parser/vendor/http-parser-java/README.md +23 -143
  13. data/ext/ruby_http_parser/vendor/http-parser-java/TODO +3 -0
  14. data/ext/ruby_http_parser/vendor/http-parser-java/build.xml +74 -0
  15. data/ext/ruby_http_parser/vendor/http-parser-java/ext/primitives.jar +0 -0
  16. data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.c +115 -61
  17. data/ext/ruby_http_parser/vendor/http-parser-java/http_parser.h +19 -3
  18. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPCallback.java +8 -0
  19. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPDataCallback.java +34 -0
  20. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPErrorCallback.java +12 -0
  21. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPException.java +4 -2
  22. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPMethod.java +64 -52
  23. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/HTTPParser.java +5 -0
  24. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/ParserSettings.java +323 -0
  25. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/{lolevel/Util.java → Util.java} +27 -28
  26. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/HTTPParser.java +259 -85
  27. data/ext/ruby_http_parser/vendor/http-parser-java/src/impl/http_parser/lolevel/ParserSettings.java +1 -0
  28. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Message.java +324 -0
  29. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Requests.java +69 -0
  30. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Responses.java +51 -0
  31. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Test.java +15 -0
  32. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java +47 -0
  33. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestLoaderNG.java +183 -447
  34. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java +61 -0
  35. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/UnitTest.java +2 -1
  36. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Upgrade.java +26 -0
  37. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/Util.java +165 -0
  38. data/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java +58 -0
  39. data/ext/ruby_http_parser/vendor/http-parser-java/test.c +232 -29
  40. data/ext/ruby_http_parser/vendor/http-parser-java/test_permutations +1 -1
  41. data/ext/ruby_http_parser/vendor/http-parser-java/test_unit +1 -1
  42. data/ext/ruby_http_parser/vendor/http-parser-java/test_utf8 +1 -0
  43. data/ext/ruby_http_parser/vendor/http-parser-java/tests.dumped +154 -7
  44. data/ext/ruby_http_parser/vendor/http-parser-java/tests.utf8 +17 -0
  45. data/http_parser.rb.gemspec +8 -2
  46. data/lib/http_parser.rb +17 -0
  47. data/spec/parser_spec.rb +116 -6
  48. data/tasks/compile.rake +3 -1
  49. data/tasks/fixtures.rake +1 -1
  50. metadata +169 -125
  51. 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 home.netscape.com:443 HTTP/1.0\r\nUser-agent: Mozilla/1.1N\r\nProxy-authorization: basic aGVsbG86d29ybGQ=\r\n\r\n"
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 :home.netscape.com:443
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: REPORT
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: 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"
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 :{ "Cache-Control": "public, max-age=2592000"}
356
- header_5 :{ "Server": "gws"}
357
- header_6 :{ "Content-Length": "219"}
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
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "http_parser.rb"
3
- s.version = "0.5.1"
3
+ s.version = "0.5.3"
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.5'
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/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,6 +27,35 @@ 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
42
+ end
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)
30
59
  end
31
60
 
32
61
  it "should implement basic api" do
@@ -106,6 +135,25 @@ describe HTTP::Parser do
106
135
  @parser.fragment.should be_nil
107
136
  end
108
137
 
138
+ it "should optionally reset parser state on no-body responses" do
139
+ @parser.reset!.should be_true
140
+
141
+ @head, @complete = 0, 0
142
+ @parser.on_headers_complete = proc {|h| @head += 1; :reset }
143
+ @parser.on_message_complete = proc { @complete += 1 }
144
+ @parser.on_body = proc {|b| fail }
145
+
146
+ head_response = "HTTP/1.1 200 OK\r\nContent-Length:10\r\n\r\n"
147
+
148
+ @parser << head_response
149
+ @head.should == 1
150
+ @complete.should == 1
151
+
152
+ @parser << head_response
153
+ @head.should == 2
154
+ @complete.should == 2
155
+ end
156
+
109
157
  it "should retain callbacks after reset" do
110
158
  @parser.reset!.should be_true
111
159
 
@@ -132,16 +180,57 @@ describe HTTP::Parser do
132
180
  }
133
181
  end
134
182
 
135
- it "should handle multiple headers" do
183
+ it "should handle multiple headers using strings" do
184
+ @parser.header_value_type = :strings
185
+
136
186
  @parser <<
137
187
  "GET / HTTP/1.0\r\n" +
138
- "Header: value 1\r\n" +
139
- "Header: value 2\r\n" +
188
+ "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
189
+ "Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" +
140
190
  "\r\n"
141
191
 
142
- @parser.headers.should == {
143
- 'Header' => 'value 1, value 2'
144
- }
192
+ @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"
193
+ end
194
+
195
+ it "should handle multiple headers using strings" do
196
+ @parser.header_value_type = :arrays
197
+
198
+ @parser <<
199
+ "GET / HTTP/1.0\r\n" +
200
+ "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
201
+ "Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" +
202
+ "\r\n"
203
+
204
+ @parser.headers["Set-Cookie"].should == [
205
+ "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com",
206
+ "NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly"
207
+ ]
208
+ end
209
+
210
+ it "should handle multiple headers using mixed" do
211
+ @parser.header_value_type = :mixed
212
+
213
+ @parser <<
214
+ "GET / HTTP/1.0\r\n" +
215
+ "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
216
+ "Set-Cookie: NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly\r\n" +
217
+ "\r\n"
218
+
219
+ @parser.headers["Set-Cookie"].should == [
220
+ "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com",
221
+ "NID=46jSHxPM; path=/; domain=.bob.com; HttpOnly"
222
+ ]
223
+ end
224
+
225
+ it "should handle a single cookie using mixed" do
226
+ @parser.header_value_type = :mixed
227
+
228
+ @parser <<
229
+ "GET / HTTP/1.0\r\n" +
230
+ "Set-Cookie: PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com\r\n" +
231
+ "\r\n"
232
+
233
+ @parser.headers["Set-Cookie"].should == "PREF=ID=a7d2c98; expires=Fri, 05-Apr-2013 05:00:45 GMT; path=/; domain=.bob.com"
145
234
  end
146
235
 
147
236
  it "should support alternative api" do
@@ -172,6 +261,27 @@ describe HTTP::Parser do
172
261
  @done.should be_true
173
262
  end
174
263
 
264
+ it 'sets upgrade_data if available' do
265
+ @parser <<
266
+ "GET /demo HTTP/1.1\r\n" +
267
+ "Connection: Upgrade\r\n" +
268
+ "Upgrade: WebSocket\r\n\r\n" +
269
+ "third key data"
270
+
271
+ @parser.upgrade?.should be_true
272
+ @parser.upgrade_data.should == 'third key data'
273
+ end
274
+
275
+ it 'sets upgrade_data to blank if un-available' do
276
+ @parser <<
277
+ "GET /demo HTTP/1.1\r\n" +
278
+ "Connection: Upgrade\r\n" +
279
+ "Upgrade: WebSocket\r\n\r\n"
280
+
281
+ @parser.upgrade?.should be_true
282
+ @parser.upgrade_data.should == ''
283
+ end
284
+
175
285
  %w[ request response ].each do |type|
176
286
  JSON.parse(File.read(File.expand_path("../support/#{type}s.json", __FILE__))).each do |test|
177
287
  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/
data/tasks/fixtures.rake CHANGED
@@ -15,7 +15,7 @@ task :fixtures => :submodules do
15
15
  tmp.gsub!('FALSE', 'false')
16
16
 
17
17
  # remove macros and comments
18
- tmp.gsub!(/^#define.+$/,'')
18
+ tmp.gsub!(/^#(if|elif|endif|define).+$/,'')
19
19
  tmp.gsub!(/\/\*(.+?)\*\/$/,'')
20
20
 
21
21
  # HTTP_* enums become strings