noderb-http 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ CASES << {
2
+ :name => "upgrade request",
3
+ :type => :request,
4
+ :message_complete_on_eof => false,
5
+ :data => [
6
+ "GET /demo HTTP/1.1\n",
7
+ "Host: example.com\n",
8
+ "Connection: Upgrade\n",
9
+ "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\n",
10
+ "Sec-WebSocket-Protocol: sample\n",
11
+ "Upgrade: WebSocket\n",
12
+ "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\n",
13
+ "Origin: http://example.com\n",
14
+ "\n",
15
+ "Hot diggity dogg"
16
+ ],
17
+ :should_keep_alive => true,
18
+ :http_major => 1,
19
+ :http_minor => 1,
20
+ :method => "GET",
21
+ :request_url => "/demo",
22
+ :num_headers => 7,
23
+ :headers => {
24
+ "Host" => "example.com",
25
+ "Connection" => "Upgrade",
26
+ "Sec-WebSocket-Key2" => "12998 5 Y3 1 .P00",
27
+ "Sec-WebSocket-Protocol" => "sample",
28
+ "Upgrade" => "WebSocket",
29
+ "Sec-WebSocket-Key1" => "4 @1 46546xW%0l 1 5",
30
+ "Origin" => "http://example.com"
31
+ },
32
+ :upgrade => true,
33
+ :body => ""
34
+ }
data/test/init.rb ADDED
@@ -0,0 +1,62 @@
1
+ $: << File.expand_path("../../ext/noderb_http_extension", __FILE__)
2
+ $: << File.expand_path("../../lib", __FILE__)
3
+
4
+ require "noderb-http"
5
+
6
+ class TestParser
7
+
8
+ include NodeRb::Modules::Http::Parser
9
+
10
+ attr_accessor :headers, :version_major, :version_minor, :method, :url, :body, :keep_alive, :upgrade
11
+
12
+ def on_message_header
13
+ end
14
+
15
+ def on_message_body
16
+ end
17
+
18
+ def on_message_error name, desc
19
+ puts name
20
+ puts desc
21
+ end
22
+
23
+ end
24
+
25
+ def check_result parser, test
26
+ errors = []
27
+ errors << :http_major unless test[:http_major] == parser.version_major
28
+ errors << :http_minor unless test[:http_minor] == parser.version_minor
29
+ errors << :method unless test[:method] == parser.method
30
+ errors << :request_url unless test[:request_url] == parser.url
31
+ errors << :headers unless test[:headers] == parser.headers
32
+ errors << :should_keep_alive unless test[:should_keep_alive] == parser.keep_alive
33
+ errors << :body unless test[:body] == parser.body
34
+ errors << :upgrade unless test[:upgrade] == parser.upgrade
35
+ errors
36
+ end
37
+
38
+ CASES = []
39
+
40
+ Dir.glob(File.expand_path("../cases/*.rb", __FILE__)) do |file|
41
+ require file
42
+ end
43
+
44
+ failed = false
45
+ CASES.each do |test|
46
+ parser = TestParser.new
47
+ parser.setup(test[:type])
48
+ if test[:data].kind_of?(String)
49
+ parser.parse(test[:data])
50
+ else
51
+ test[:data].each do |data|
52
+ parser.parse(data)
53
+ end
54
+ end
55
+ result = check_result(parser, test)
56
+ if result.length > 0
57
+ puts "** Test <#{test[:name]}> failed on #{result}" if result != "OK"
58
+ failed = true
59
+ end
60
+ end
61
+
62
+ puts "** All test passed OK" unless failed
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noderb-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-24 00:00:00.000000000Z
12
+ date: 2011-08-10 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Fast and full-featured HTTP parser.
15
15
  email:
@@ -19,15 +19,24 @@ extensions:
19
19
  - ext/noderb_http_extension/extconf.rb
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - lib/noderb/modules/http/parser.rb
23
+ - lib/noderb/modules/http/version.rb
22
24
  - lib/noderb/modules/http.rb
23
25
  - lib/noderb-http.rb
24
- - ext/http_parser.o
25
- - ext/noderb_http.o
26
26
  - ext/noderb_http_extension/extconf.rb
27
27
  - ext/noderb_http_extension/http_parser.c
28
28
  - ext/noderb_http_extension/http_parser.h
29
+ - ext/noderb_http_extension/http_parser.o
30
+ - ext/noderb_http_extension/Makefile
29
31
  - ext/noderb_http_extension/noderb_http.c
30
32
  - ext/noderb_http_extension/noderb_http.h
33
+ - ext/noderb_http_extension/noderb_http.o
34
+ - ext/noderb_http_extension/noderb_http_extension.bundle
35
+ - test/cases/curl_get.rb
36
+ - test/cases/patch_request.rb
37
+ - test/cases/response.rb
38
+ - test/cases/upgrade_request.rb
39
+ - test/init.rb
31
40
  - LICENSE
32
41
  - README.md
33
42
  homepage: http://github.com/noderb/noderb-http
@@ -36,7 +45,6 @@ post_install_message:
36
45
  rdoc_options: []
37
46
  require_paths:
38
47
  - lib
39
- - ext
40
48
  required_ruby_version: !ruby/object:Gem::Requirement
41
49
  none: false
42
50
  requirements:
data/ext/http_parser.o DELETED
Binary file
data/ext/noderb_http.o DELETED
Binary file