websocket 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +37 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/Rakefile +3 -3
- data/lib/websocket.rb +2 -3
- data/lib/websocket/error.rb +57 -25
- data/lib/websocket/exception_handler.rb +2 -14
- data/lib/websocket/frame.rb +0 -2
- data/lib/websocket/frame/base.rb +12 -13
- data/lib/websocket/frame/data.rb +1 -3
- data/lib/websocket/frame/handler.rb +0 -2
- data/lib/websocket/frame/handler/base.rb +2 -4
- data/lib/websocket/frame/handler/handler03.rb +149 -112
- data/lib/websocket/frame/handler/handler04.rb +3 -3
- data/lib/websocket/frame/handler/handler05.rb +3 -3
- data/lib/websocket/frame/handler/handler07.rb +8 -10
- data/lib/websocket/frame/handler/handler75.rb +10 -12
- data/lib/websocket/frame/incoming.rb +0 -2
- data/lib/websocket/frame/incoming/client.rb +0 -2
- data/lib/websocket/frame/incoming/server.rb +0 -2
- data/lib/websocket/frame/outgoing.rb +1 -3
- data/lib/websocket/frame/outgoing/client.rb +0 -2
- data/lib/websocket/frame/outgoing/server.rb +0 -2
- data/lib/websocket/handshake.rb +0 -2
- data/lib/websocket/handshake/base.rb +10 -9
- data/lib/websocket/handshake/client.rb +22 -35
- data/lib/websocket/handshake/handler.rb +0 -2
- data/lib/websocket/handshake/handler/base.rb +0 -2
- data/lib/websocket/handshake/handler/client.rb +0 -2
- data/lib/websocket/handshake/handler/client01.rb +0 -2
- data/lib/websocket/handshake/handler/client04.rb +3 -5
- data/lib/websocket/handshake/handler/client11.rb +0 -2
- data/lib/websocket/handshake/handler/client75.rb +2 -4
- data/lib/websocket/handshake/handler/client76.rb +6 -8
- data/lib/websocket/handshake/handler/server.rb +0 -1
- data/lib/websocket/handshake/handler/server04.rb +3 -5
- data/lib/websocket/handshake/handler/server75.rb +2 -4
- data/lib/websocket/handshake/handler/server76.rb +7 -9
- data/lib/websocket/handshake/server.rb +19 -24
- data/lib/websocket/version.rb +1 -1
- data/spec/frame/incoming_03_spec.rb +1 -2
- data/spec/frame/incoming_04_spec.rb +1 -2
- data/spec/frame/incoming_05_spec.rb +1 -2
- data/spec/frame/incoming_07_spec.rb +1 -2
- data/spec/frame/incoming_75_spec.rb +1 -2
- data/spec/support/all_client_drafts.rb +1 -1
- data/spec/support/all_server_drafts.rb +7 -10
- data/spec/support/frames_base.rb +0 -2
- data/spec/support/handshake_requests.rb +4 -4
- data/spec/support/outgoing_frames.rb +0 -1
- data/spec/support/overwrites.rb +0 -2
- data/websocket.gemspec +10 -10
- metadata +4 -3
@@ -22,7 +22,7 @@ RSpec.describe 'Incoming frame draft 75' do
|
|
22
22
|
|
23
23
|
context 'with two frames' do
|
24
24
|
let(:encoded_text) { "\x00abc\xFF\x00def\xFF" }
|
25
|
-
let(:decoded_text) {
|
25
|
+
let(:decoded_text) { %w(abc def) }
|
26
26
|
let(:frame_type) { [:text, :text] }
|
27
27
|
|
28
28
|
it_should_behave_like 'valid_incoming_frame'
|
@@ -56,5 +56,4 @@ RSpec.describe 'Incoming frame draft 75' do
|
|
56
56
|
|
57
57
|
it_should_behave_like 'valid_incoming_frame'
|
58
58
|
end
|
59
|
-
|
60
59
|
end
|
@@ -43,7 +43,7 @@ RSpec.shared_examples_for 'all client drafts' do
|
|
43
43
|
|
44
44
|
it 'should return valid headers' do
|
45
45
|
@request_params = { headers: { 'aaa' => 'bbb' } }
|
46
|
-
expect(handshake.headers).to eql(
|
46
|
+
expect(handshake.headers).to eql('aaa' => 'bbb')
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should parse uri' do
|
@@ -87,10 +87,10 @@ RSpec.shared_examples_for 'all server drafts' do
|
|
87
87
|
it 'should parse a rack request' do
|
88
88
|
request = WEBrick::HTTPRequest.new(ServerSoftware: 'rspec')
|
89
89
|
expect(request.parse(StringIO.new(client_request))).to be true
|
90
|
-
rest
|
90
|
+
rest = client_request.slice((request.to_s.length..-1))
|
91
91
|
|
92
92
|
handshake.from_rack(request.meta_vars.merge(
|
93
|
-
|
93
|
+
'rack.input' => StringIO.new(rest)
|
94
94
|
))
|
95
95
|
validate_request
|
96
96
|
end
|
@@ -102,17 +102,14 @@ RSpec.shared_examples_for 'all server drafts' do
|
|
102
102
|
|
103
103
|
path = request.path
|
104
104
|
query = request.query_string
|
105
|
-
headers = request.header.
|
105
|
+
headers = request.header.each_with_object({}) do |header, hash|
|
106
106
|
hash[header[0]] = header[1].first if header[0] && header[1]
|
107
|
-
hash
|
108
107
|
end
|
109
108
|
|
110
|
-
handshake.from_hash(
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
body: body
|
115
|
-
})
|
109
|
+
handshake.from_hash(headers: headers,
|
110
|
+
path: path,
|
111
|
+
query: query,
|
112
|
+
body: body)
|
116
113
|
|
117
114
|
validate_request
|
118
115
|
end
|
data/spec/support/frames_base.rb
CHANGED
@@ -5,7 +5,7 @@ Upgrade: WebSocket\r
|
|
5
5
|
Connection: Upgrade\r
|
6
6
|
Host: #{args[:host] || 'example.com'}#{":#{args[:port]}" if args[:port]}\r
|
7
7
|
Origin: http://example.com\r
|
8
|
-
#{(args[:headers] || {}).map{|key, value| "#{key}: #{value}\r\n"}.join('')}\r
|
8
|
+
#{(args[:headers] || {}).map { |key, value| "#{key}: #{value}\r\n" }.join('')}\r
|
9
9
|
EOF
|
10
10
|
end
|
11
11
|
|
@@ -27,7 +27,7 @@ Upgrade: WebSocket\r
|
|
27
27
|
Connection: Upgrade\r
|
28
28
|
Host: #{args[:host] || 'example.com'}#{":#{args[:port]}" if args[:port]}\r
|
29
29
|
Origin: http://example.com\r
|
30
|
-
#{(args[:headers] || {}).map{|key, value| "#{key}: #{value}\r\n"}.join('')}Sec-WebSocket-Key1: #{args[:key1] || '4 @1 46546xW%0l 1 5'}\r
|
30
|
+
#{(args[:headers] || {}).map { |key, value| "#{key}: #{value}\r\n" }.join('')}Sec-WebSocket-Key1: #{args[:key1] || '4 @1 46546xW%0l 1 5'}\r
|
31
31
|
Sec-WebSocket-Key2: #{args[:key2] || '12998 5 Y3 1 .P00'}\r
|
32
32
|
\r
|
33
33
|
#{args[:key3] || '^n:ds[4U'}
|
@@ -54,7 +54,7 @@ GET #{args[:path] || '/demo'}#{"?#{args[:query]}" if args[:query]} HTTP/1.1\r
|
|
54
54
|
Upgrade: websocket\r
|
55
55
|
Connection: Upgrade\r
|
56
56
|
Host: #{args[:host] || 'example.com'}#{":#{args[:port]}" if args[:port]}\r
|
57
|
-
#{(args[:headers] || {}).map{|key, value| "#{key}: #{value}\r\n"}.join('')}Sec-WebSocket-Origin: http://example.com\r
|
57
|
+
#{(args[:headers] || {}).map { |key, value| "#{key}: #{value}\r\n" }.join('')}Sec-WebSocket-Origin: http://example.com\r
|
58
58
|
Sec-WebSocket-Version: #{args[:version] || '4'}\r
|
59
59
|
Sec-WebSocket-Key: #{args[:key] || 'dGhlIHNhbXBsZSBub25jZQ=='}\r
|
60
60
|
\r
|
@@ -77,7 +77,7 @@ GET #{args[:path] || '/demo'}#{"?#{args[:query]}" if args[:query]} HTTP/1.1\r
|
|
77
77
|
Upgrade: websocket\r
|
78
78
|
Connection: Upgrade\r
|
79
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
|
80
|
+
#{(args[:headers] || {}).map { |key, value| "#{key}: #{value}\r\n" }.join('')}Origin: http://example.com\r
|
81
81
|
Sec-WebSocket-Version: #{args[:version] || '4'}\r
|
82
82
|
Sec-WebSocket-Key: #{args[:key] || 'dGhlIHNhbXBsZSBub25jZQ=='}\r
|
83
83
|
\r
|
data/spec/support/overwrites.rb
CHANGED
data/websocket.gemspec
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'websocket/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'websocket'
|
7
7
|
s.version = WebSocket::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.homepage =
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
14
|
-
s.license =
|
9
|
+
s.authors = ['Bernard Potocki']
|
10
|
+
s.email = ['bernard.potocki@imanel.org']
|
11
|
+
s.homepage = 'http://github.com/imanel/websocket-ruby'
|
12
|
+
s.summary = 'Universal Ruby library to handle WebSocket protocol'
|
13
|
+
s.description = 'Universal Ruby library to handle WebSocket protocol'
|
14
|
+
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
19
|
+
s.require_paths = ['lib']
|
20
20
|
end
|
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.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Potocki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Universal Ruby library to handle WebSocket protocol
|
14
14
|
email:
|
@@ -18,6 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
+
- ".rubocop.yml"
|
21
22
|
- ".travis.yml"
|
22
23
|
- CHANGELOG.md
|
23
24
|
- Gemfile
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
111
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.1
|
112
113
|
signing_key:
|
113
114
|
specification_version: 4
|
114
115
|
summary: Universal Ruby library to handle WebSocket protocol
|