websocket 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1abaa63e74cec12f6ac238b27501082a869a80e9
4
- data.tar.gz: ff59280d0bb38c24bed57aca2b32b312770ec52d
3
+ metadata.gz: 7ca690c7a42466b8cb035271b77010bdc7bf8a19
4
+ data.tar.gz: 206ca9afa7b5606cb08b85ef66a8f186342d37b3
5
5
  SHA512:
6
- metadata.gz: 4e55e294a520f621923af31e70c6f919fc8da3b84d86a312cfc3aa581415a8123a587891732429140fe7b3e7718ad997baa9bd33b4448b268e4a2af3b44c88a2
7
- data.tar.gz: f083f50a27c58a4065cd685d5906186cd07d35da5f6577a1d14dd0b36cd21f287a012b5faef818bd9345331d4d91ed1367bdcdb97c58a0029d27f7c5d435bb54
6
+ metadata.gz: 6b846fa2663e5f85415adc35e2aa39e0e7b21f844b444546c432a6b630c79d4aa4aabf5dbaf996c6334b80e1296b81a35a0935a51a9d0cfa55d6a748fb1762b7
7
+ data.tar.gz: cbf090a638401a094b7432f7a634ba7bc2f8fcd77b06e0407a8d2490f3236858368d619a6acf17296a715824c239b1c51beb5577597af91133e6c6472338c659
@@ -2,9 +2,9 @@ language: ruby
2
2
  script: "bundle exec rake spec"
3
3
  rvm:
4
4
  - 1.9.3
5
- - 2.0.0
6
- - 2.1.1
7
- - 2.1.2
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
8
  - rbx-2
9
9
  - jruby-19mode
10
10
  - ruby-head
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2
4
+
5
+ - fix handshake for draft 11+ sending Sec-WebSocket-Origin instead of Origin
6
+
3
7
  ## 1.2.1
4
8
 
5
9
  - fix error for draft 76 when leftovers are empty
data/README.md CHANGED
@@ -40,7 +40,7 @@ GET /demo HTTP/1.1\r
40
40
  Upgrade: websocket\r
41
41
  Connection: Upgrade\r
42
42
  Host: example.com\r
43
- Sec-WebSocket-Origin: http://example.com\r
43
+ Origin: http://example.com\r
44
44
  Sec-WebSocket-Version: 13\r
45
45
  Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
46
46
  \r
@@ -70,7 +70,7 @@ EOF
70
70
  # Connection: Upgrade
71
71
  # Host: example.com
72
72
  # Cookie: SESSIONID=1234
73
- # Sec-WebSocket-Origin: http://example.com
73
+ # Origin: http://example.com
74
74
  # Sec-WebSocket-Version: 13
75
75
  # Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
76
76
 
@@ -12,7 +12,7 @@ module WebSocket
12
12
  # # Upgrade: websocket
13
13
  # # Connection: Upgrade
14
14
  # # Host: example.com
15
- # # Sec-WebSocket-Origin: http://example.com
15
+ # # Origin: http://example.com
16
16
  # # Sec-WebSocket-Version: 13
17
17
  # # Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
18
18
  #
@@ -117,7 +117,8 @@ module WebSocket
117
117
  when 75 then Handler::Client75.new(self)
118
118
  when 76, 0 then Handler::Client76.new(self)
119
119
  when 1..3 then Handler::Client01.new(self)
120
- when 4..13 then Handler::Client04.new(self)
120
+ when 4..10 then Handler::Client04.new(self)
121
+ when 11..17 then Handler::Client11.new(self)
121
122
  else raise WebSocket::Error::Handshake::UnknownVersion
122
123
  end
123
124
  end
@@ -7,6 +7,7 @@ module WebSocket
7
7
  autoload :Client, "#{::WebSocket::ROOT}/websocket/handshake/handler/client"
8
8
  autoload :Client01, "#{::WebSocket::ROOT}/websocket/handshake/handler/client01"
9
9
  autoload :Client04, "#{::WebSocket::ROOT}/websocket/handshake/handler/client04"
10
+ autoload :Client11, "#{::WebSocket::ROOT}/websocket/handshake/handler/client11"
10
11
  autoload :Client75, "#{::WebSocket::ROOT}/websocket/handshake/handler/client75"
11
12
  autoload :Client76, "#{::WebSocket::ROOT}/websocket/handshake/handler/client76"
12
13
 
@@ -0,0 +1,22 @@
1
+ module WebSocket
2
+ module Handshake
3
+ module Handler
4
+ class Client11 < Client04
5
+
6
+ private
7
+
8
+ # @see WebSocket::Handshake::Handler::Base#handshake_keys
9
+ def handshake_keys
10
+ super.collect do |key_pair|
11
+ if key_pair[0] == 'Sec-WebSocket-Origin'
12
+ ['Origin', key_pair[1]]
13
+ else
14
+ key_pair
15
+ end
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -11,7 +11,7 @@ module WebSocket
11
11
  # Upgrade: websocket\r
12
12
  # Connection: Upgrade\r
13
13
  # Host: example.com\r
14
- # Sec-WebSocket-Origin: http://example.com\r
14
+ # Origin: http://example.com\r
15
15
  # Sec-WebSocket-Version: 13\r
16
16
  # Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
17
17
  # \r
@@ -54,7 +54,7 @@ module WebSocket
54
54
  # Upgrade: websocket
55
55
  # Connection: Upgrade
56
56
  # Host: example.com
57
- # Sec-WebSocket-Origin: http://example.com
57
+ # Origin: http://example.com
58
58
  # Sec-WebSocket-Version: 13
59
59
  # Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
60
60
  #
@@ -156,7 +156,7 @@ module WebSocket
156
156
  @handler = case @version
157
157
  when 75 then Handler::Server75.new(self)
158
158
  when 76, 0..3 then Handler::Server76.new(self)
159
- when 4..13 then Handler::Server04.new(self)
159
+ when 4..17 then Handler::Server04.new(self)
160
160
  else raise WebSocket::Error::Handshake::UnknownVersion
161
161
  end
162
162
  end
@@ -1,3 +1,3 @@
1
1
  module WebSocket
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Client draft 11 handshake' do
4
+ let(:handshake) { WebSocket::Handshake::Client.new({ uri: 'ws://example.com/demo', origin: 'http://example.com', version: version }.merge(@request_params || {})) }
5
+
6
+ let(:version) { 11 }
7
+ let(:client_request) { client_handshake_11({ key: handshake.handler.send(:key), version: version }.merge(@request_params || {})) }
8
+ let(:server_response) { server_handshake_11({ accept: handshake.handler.send(:accept) }.merge(@request_params || {})) }
9
+
10
+ it_should_behave_like 'all client drafts'
11
+
12
+ it 'should disallow client with invalid challenge' do
13
+ @request_params = { accept: 'invalid' }
14
+ handshake << server_response
15
+
16
+ expect(handshake).to be_finished
17
+ expect(handshake).not_to be_valid
18
+ expect(handshake.error).to eql(:invalid_handshake_authentication)
19
+ end
20
+ end
@@ -70,3 +70,20 @@ Sec-WebSocket-Accept: #{args[:accept] || 's3pPLMBiTxaQ9kYGzzhZRbK+xOo='}\r
70
70
  \r
71
71
  EOF
72
72
  end
73
+
74
+ def client_handshake_11(args = {})
75
+ <<-EOF
76
+ GET #{args[:path] || '/demo'}#{"?#{args[:query]}" if args[:query]} HTTP/1.1\r
77
+ Upgrade: websocket\r
78
+ Connection: Upgrade\r
79
+ Host: #{args[:host] || 'example.com'}#{":#{args[:port]}" if args[:port]}\r
80
+ #{(args[:headers] || {}).map{|key, value| "#{key}: #{value}\r\n"}.join('')}Origin: http://example.com\r
81
+ Sec-WebSocket-Version: #{args[:version] || '4'}\r
82
+ Sec-WebSocket-Key: #{args[:key] || 'dGhlIHNhbXBsZSBub25jZQ=='}\r
83
+ \r
84
+ EOF
85
+ end
86
+
87
+ def server_handshake_11(args = {})
88
+ server_handshake_04(args)
89
+ end
@@ -9,8 +9,9 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Bernard Potocki"]
10
10
  s.email = ["bernard.potocki@imanel.org"]
11
11
  s.homepage = "http://github.com/imanel/websocket-ruby"
12
- s.summary = %q{Universal Ruby library to handle WebSocket protocol}
13
- s.description = %q{Universal Ruby library to handle WebSocket protocol}
12
+ s.summary = "Universal Ruby library to handle WebSocket protocol"
13
+ s.description = "Universal Ruby library to handle WebSocket protocol"
14
+ s.license = "MIT"
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Potocki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Universal Ruby library to handle WebSocket protocol
14
14
  email:
@@ -50,6 +50,7 @@ files:
50
50
  - lib/websocket/handshake/handler/client.rb
51
51
  - lib/websocket/handshake/handler/client01.rb
52
52
  - lib/websocket/handshake/handler/client04.rb
53
+ - lib/websocket/handshake/handler/client11.rb
53
54
  - lib/websocket/handshake/handler/client75.rb
54
55
  - lib/websocket/handshake/handler/client76.rb
55
56
  - lib/websocket/handshake/handler/server.rb
@@ -72,6 +73,7 @@ files:
72
73
  - spec/frame/outgoing_75_spec.rb
73
74
  - spec/frame/outgoing_common_spec.rb
74
75
  - spec/handshake/client_04_spec.rb
76
+ - spec/handshake/client_11_spec.rb
75
77
  - spec/handshake/client_75_spec.rb
76
78
  - spec/handshake/client_76_spec.rb
77
79
  - spec/handshake/server_04_spec.rb
@@ -87,7 +89,8 @@ files:
87
89
  - spec/support/overwrites.rb
88
90
  - websocket.gemspec
89
91
  homepage: http://github.com/imanel/websocket-ruby
90
- licenses: []
92
+ licenses:
93
+ - MIT
91
94
  metadata: {}
92
95
  post_install_message:
93
96
  rdoc_options: []
@@ -105,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
108
  version: '0'
106
109
  requirements: []
107
110
  rubyforge_project:
108
- rubygems_version: 2.2.2
111
+ rubygems_version: 2.4.5
109
112
  signing_key:
110
113
  specification_version: 4
111
114
  summary: Universal Ruby library to handle WebSocket protocol
@@ -124,6 +127,7 @@ test_files:
124
127
  - spec/frame/outgoing_75_spec.rb
125
128
  - spec/frame/outgoing_common_spec.rb
126
129
  - spec/handshake/client_04_spec.rb
130
+ - spec/handshake/client_11_spec.rb
127
131
  - spec/handshake/client_75_spec.rb
128
132
  - spec/handshake/client_76_spec.rb
129
133
  - spec/handshake/server_04_spec.rb