websocket 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
- ## 1.0.0 / 2012-11-18
3
+ ## 1.0.1
4
+
5
+ - allow creating client with :uri and :url options
6
+ - prevent strange results when header is mailformed
7
+ - set client path to '/' when :uri option is provided but without trailing slash
8
+
9
+ ## 1.0.0
4
10
 
5
11
  - initial release
data/autobahn-server.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "options": {"failByDrop": false},
3
3
  "outdir": "./autobahn/server",
4
4
 
5
- "servers": [{"agent": "WebSocket-Ruby v1.0.0", "url": "ws://localhost:9001", "options": {"version": 18}}],
5
+ "servers": [{"agent": "WebSocket-Ruby v1.0.1", "url": "ws://localhost:9001", "options": {"version": 18}}],
6
6
 
7
7
  "cases": ["*"],
8
8
  "exclude-cases": [],
@@ -10,8 +10,8 @@ module WebSocket
10
10
  @version = args[:version] || DEFAULT_VERSION
11
11
  @origin = args[:origin]
12
12
 
13
- if args[:uri]
14
- uri = URI.parse(args[:uri])
13
+ if args[:url] || args[:uri]
14
+ uri = URI.parse(args[:url] || args[:uri])
15
15
  @secure = (uri.scheme == 'wss')
16
16
  @host = uri.host
17
17
  @port = uri.port
@@ -25,7 +25,7 @@ module WebSocket
25
25
  @path = args[:path] if args[:path]
26
26
  @query = args[:query] if args[:query]
27
27
 
28
- @path ||= '/'
28
+ @path = '/' if @path.nil? || @path.empty?
29
29
 
30
30
  set_error(:no_host_provided) unless @host
31
31
 
@@ -69,6 +69,7 @@ module WebSocket
69
69
 
70
70
  def parse_first_line(line)
71
71
  line_parts = line.match(FIRST_LINE)
72
+ set_error(:invalid_header) and return unless line_parts
72
73
  status = line_parts[1]
73
74
  set_error(:invalid_status_code) and return unless status == '101'
74
75
 
@@ -42,6 +42,7 @@ module WebSocket
42
42
 
43
43
  def parse_first_line(line)
44
44
  line_parts = line.match(PATH)
45
+ set_error(:invalid_header) and return unless line_parts
45
46
  method = line_parts[1].strip
46
47
  set_error(:get_request_required) and return unless method == "GET"
47
48
 
@@ -1,3 +1,3 @@
1
1
  module WebSocket
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -41,6 +41,27 @@ shared_examples_for 'all client drafts' do
41
41
  handshake.port.should eql(123)
42
42
  end
43
43
 
44
+ it "should parse uri" do
45
+ @request_params = { :uri => "ws://test.example.org:301/test_path?query=true" }
46
+ handshake.host.should eql('test.example.org')
47
+ handshake.port.should eql(301)
48
+ handshake.path.should eql('/test_path')
49
+ handshake.query.should eql('query=true')
50
+ end
51
+
52
+ it "should parse url" do
53
+ @request_params = { :url => "ws://test.example.org:301/test_path?query=true" }
54
+ handshake.host.should eql('test.example.org')
55
+ handshake.port.should eql(301)
56
+ handshake.path.should eql('/test_path')
57
+ handshake.query.should eql('query=true')
58
+ end
59
+
60
+ it "should resolve correct path with root server provided" do
61
+ @request_params = { :url => "ws://test.example.org" }
62
+ handshake.path.should eql('/')
63
+ end
64
+
44
65
  it "should return valid response" do
45
66
  validate_request
46
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: -4164507600771502343
123
+ hash: -2471372616907526003
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements:
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  segments:
131
131
  - 0
132
- hash: -4164507600771502343
132
+ hash: -2471372616907526003
133
133
  requirements: []
134
134
  rubyforge_project:
135
135
  rubygems_version: 1.8.24