websocket 1.2.4 → 1.2.5
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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +16 -0
- data/.rubocop.yml +18 -3
- data/.travis.yml +6 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile +10 -0
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/lib/websocket.rb +1 -0
- data/lib/websocket/frame/base.rb +1 -7
- data/lib/websocket/frame/handler/base.rb +2 -2
- data/lib/websocket/frame/handler/handler03.rb +2 -1
- data/lib/websocket/frame/handler/handler75.rb +1 -1
- data/lib/websocket/handshake/base.rb +1 -7
- data/lib/websocket/handshake/handler/client.rb +9 -0
- data/lib/websocket/handshake/handler/client04.rb +6 -7
- data/lib/websocket/handshake/handler/client75.rb +6 -7
- data/lib/websocket/handshake/handler/client76.rb +2 -7
- data/lib/websocket/handshake/handler/server75.rb +13 -5
- data/lib/websocket/handshake/handler/server76.rb +9 -17
- data/lib/websocket/handshake/server.rb +1 -1
- data/lib/websocket/nice_inspect.rb +10 -0
- data/lib/websocket/version.rb +1 -1
- data/spec/frame/incoming_03_spec.rb +3 -2
- data/spec/frame/incoming_04_spec.rb +3 -2
- data/spec/frame/incoming_05_spec.rb +3 -2
- data/spec/frame/incoming_07_spec.rb +3 -2
- data/spec/frame/incoming_75_spec.rb +3 -2
- data/spec/frame/incoming_common_spec.rb +17 -8
- data/spec/frame/masking_spec.rb +2 -1
- data/spec/frame/outgoing_03_spec.rb +2 -1
- data/spec/frame/outgoing_04_spec.rb +2 -1
- data/spec/frame/outgoing_05_spec.rb +2 -1
- data/spec/frame/outgoing_07_spec.rb +2 -1
- data/spec/frame/outgoing_75_spec.rb +2 -1
- data/spec/frame/outgoing_common_spec.rb +10 -4
- data/spec/handshake/client_04_spec.rb +3 -3
- data/spec/handshake/client_11_spec.rb +2 -2
- data/spec/handshake/client_75_spec.rb +1 -1
- data/spec/handshake/client_76_spec.rb +3 -3
- data/spec/handshake/server_04_spec.rb +2 -2
- data/spec/handshake/server_76_spec.rb +8 -8
- data/spec/spec_helper.rb +0 -2
- data/spec/support/all_client_drafts.rb +21 -21
- data/spec/support/all_server_drafts.rb +19 -16
- data/spec/support/incoming_frames.rb +29 -12
- data/spec/support/outgoing_frames.rb +28 -8
- data/websocket.gemspec +2 -4
- metadata +7 -61
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
|
1
3
|
RSpec.shared_examples_for 'all server drafts' do
|
2
4
|
def validate_request
|
3
5
|
handshake << client_request
|
@@ -8,7 +10,7 @@ RSpec.shared_examples_for 'all server drafts' do
|
|
8
10
|
expect(handshake.to_s).to eql(server_response)
|
9
11
|
end
|
10
12
|
|
11
|
-
it '
|
13
|
+
it 'is valid' do
|
12
14
|
handshake << client_request
|
13
15
|
|
14
16
|
expect(handshake.error).to be_nil
|
@@ -16,86 +18,87 @@ RSpec.shared_examples_for 'all server drafts' do
|
|
16
18
|
expect(handshake).to be_valid
|
17
19
|
end
|
18
20
|
|
19
|
-
it '
|
21
|
+
it 'returns valid version' do
|
20
22
|
handshake << client_request
|
21
23
|
|
22
24
|
expect(handshake.version).to eql(version)
|
23
25
|
end
|
24
26
|
|
25
|
-
it '
|
27
|
+
it 'returns valid host' do
|
26
28
|
@request_params = { host: 'www.test.cc' }
|
27
29
|
handshake << client_request
|
28
30
|
|
29
31
|
expect(handshake.host).to eql('www.test.cc')
|
30
32
|
end
|
31
33
|
|
32
|
-
it '
|
34
|
+
it 'returns valid path' do
|
33
35
|
@request_params = { path: '/custom' }
|
34
36
|
handshake << client_request
|
35
37
|
|
36
38
|
expect(handshake.path).to eql('/custom')
|
37
39
|
end
|
38
40
|
|
39
|
-
it '
|
41
|
+
it 'returns valid query' do
|
40
42
|
@request_params = { path: '/custom?aaa=bbb' }
|
41
43
|
handshake << client_request
|
42
44
|
|
43
45
|
expect(handshake.query).to eql('aaa=bbb')
|
44
46
|
end
|
45
47
|
|
46
|
-
it '
|
48
|
+
it 'returns valid port' do
|
47
49
|
@request_params = { port: 123 }
|
48
50
|
handshake << client_request
|
49
51
|
|
50
52
|
expect(handshake.port).to eql('123')
|
51
53
|
end
|
52
54
|
|
53
|
-
it '
|
55
|
+
it 'returns valid response' do
|
54
56
|
validate_request
|
55
57
|
end
|
56
58
|
|
57
|
-
it '
|
59
|
+
it 'allows custom path' do
|
58
60
|
@request_params = { path: '/custom' }
|
59
61
|
validate_request
|
60
62
|
end
|
61
63
|
|
62
|
-
it '
|
64
|
+
it 'allows query in path' do
|
63
65
|
@request_params = { path: '/custom?test=true' }
|
64
66
|
validate_request
|
65
67
|
end
|
66
68
|
|
67
|
-
it '
|
69
|
+
it 'allows custom port' do
|
68
70
|
@request_params = { port: 123 }
|
69
71
|
validate_request
|
70
72
|
end
|
71
73
|
|
72
|
-
it '
|
74
|
+
it 'recognizes unfinished requests' do
|
73
75
|
handshake << client_request[0..-10]
|
74
76
|
|
75
77
|
expect(handshake).not_to be_finished
|
76
78
|
expect(handshake).not_to be_valid
|
77
79
|
end
|
78
80
|
|
79
|
-
it '
|
81
|
+
it 'disallows requests with invalid request method' do
|
80
82
|
handshake << client_request.gsub('GET', 'POST')
|
81
83
|
|
82
84
|
expect(handshake).to be_finished
|
83
85
|
expect(handshake).not_to be_valid
|
84
|
-
expect(handshake.error).to
|
86
|
+
expect(handshake.error).to be(:get_request_required)
|
85
87
|
end
|
86
88
|
|
87
|
-
it '
|
89
|
+
it 'parses a rack request' do
|
88
90
|
request = WEBrick::HTTPRequest.new(ServerSoftware: 'rspec')
|
89
91
|
expect(request.parse(StringIO.new(client_request))).to be true
|
90
92
|
rest = client_request.slice((request.to_s.length..-1))
|
91
93
|
|
92
94
|
handshake.from_rack(request.meta_vars.merge(
|
93
|
-
'rack.input' => StringIO.new(rest)
|
95
|
+
'rack.input' => StringIO.new(rest),
|
96
|
+
:random_key => :random_value
|
94
97
|
))
|
95
98
|
validate_request
|
96
99
|
end
|
97
100
|
|
98
|
-
it '
|
101
|
+
it 'parses a hash request' do
|
99
102
|
request = WEBrick::HTTPRequest.new(ServerSoftware: 'rspec')
|
100
103
|
expect(request.parse(StringIO.new(client_request))).to be true
|
101
104
|
body = client_request.slice((request.to_s.length..-1))
|
@@ -2,14 +2,31 @@ RSpec.shared_examples_for 'valid_incoming_frame' do
|
|
2
2
|
let(:decoded_text_array) { Array(decoded_text) }
|
3
3
|
let(:frame_type_array) { Array(frame_type) }
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
it 'is incoming frame' do
|
6
|
+
expect(subject.class).to be WebSocket::Frame::Incoming
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'is in proper verions' do
|
10
|
+
expect(subject.version).to eql version
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'does not have type set' do
|
14
|
+
expect(subject.type).to be nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is not decoded' do
|
18
|
+
expect(subject.decoded?).to be false
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'contains encoded data' do
|
22
|
+
expect(subject.data).to eql(encoded_text || '')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns data as to_s' do
|
26
|
+
expect(subject.to_s).to eql(encoded_text || '')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'has specified number of returned frames' do
|
13
30
|
decoded_text_array.each_with_index do |da, index|
|
14
31
|
n = subject.next
|
15
32
|
expect(n).not_to be_nil, "Should return frame for #{da}, #{frame_type_array[index]}"
|
@@ -23,7 +40,7 @@ RSpec.shared_examples_for 'valid_incoming_frame' do
|
|
23
40
|
end
|
24
41
|
end
|
25
42
|
|
26
|
-
it '
|
43
|
+
it 'returns valid decoded frame for each specified decoded texts' do
|
27
44
|
decoded_text_array.each_with_index do |da, index|
|
28
45
|
f = subject.next
|
29
46
|
expect(f.decoded?).to be true
|
@@ -34,10 +51,10 @@ RSpec.shared_examples_for 'valid_incoming_frame' do
|
|
34
51
|
end
|
35
52
|
|
36
53
|
context 'with raising' do
|
37
|
-
before
|
38
|
-
after
|
54
|
+
before { WebSocket.should_raise = true }
|
55
|
+
after { WebSocket.should_raise = false }
|
39
56
|
|
40
|
-
it '
|
57
|
+
it 'has specified number of returned frames' do
|
41
58
|
if error
|
42
59
|
expect do
|
43
60
|
decoded_text_array.each_with_index do |da, index|
|
@@ -1,13 +1,33 @@
|
|
1
1
|
RSpec.shared_examples_for 'valid_outgoing_frame' do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
it 'is outgoing frame' do
|
3
|
+
expect(subject.class).to be WebSocket::Frame::Outgoing
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'is in proper verions' do
|
7
|
+
expect(subject.version).to eql version
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has proper type set' do
|
11
|
+
expect(subject.type).to eql frame_type
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'contains decoded data' do
|
15
|
+
expect(subject.data).to eql(decoded_text)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns encoded data as to_s' do
|
19
|
+
expect(subject.to_s).to eql(encoded_text)
|
20
|
+
end
|
7
21
|
|
8
22
|
context 'after parsing' do
|
9
|
-
before
|
10
|
-
|
11
|
-
|
23
|
+
before { subject.to_s }
|
24
|
+
|
25
|
+
it 'has valid errors set' do
|
26
|
+
expect(subject.error).to eql error
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'requires sending' do
|
30
|
+
expect(subject.require_sending?).to eql require_sending
|
31
|
+
end
|
12
32
|
end
|
13
33
|
end
|
data/websocket.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
|
2
3
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
4
|
require 'websocket/version'
|
4
5
|
|
@@ -18,8 +19,5 @@ Gem::Specification.new do |s|
|
|
18
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
20
|
s.require_paths = ['lib']
|
20
21
|
|
21
|
-
s.
|
22
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
23
|
-
s.add_development_dependency 'rspec-its'
|
24
|
-
s.add_development_dependency 'rubocop'
|
22
|
+
s.required_ruby_version = '>= 2.0'
|
25
23
|
end
|
metadata
CHANGED
@@ -1,71 +1,15 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Potocki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec-its
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
69
13
|
description: Universal Ruby library to handle WebSocket protocol
|
70
14
|
email:
|
71
15
|
- bernard.potocki@imanel.org
|
@@ -73,6 +17,7 @@ executables: []
|
|
73
17
|
extensions: []
|
74
18
|
extra_rdoc_files: []
|
75
19
|
files:
|
20
|
+
- ".codeclimate.yml"
|
76
21
|
- ".gitignore"
|
77
22
|
- ".rubocop.yml"
|
78
23
|
- ".travis.yml"
|
@@ -115,6 +60,7 @@ files:
|
|
115
60
|
- lib/websocket/handshake/handler/server75.rb
|
116
61
|
- lib/websocket/handshake/handler/server76.rb
|
117
62
|
- lib/websocket/handshake/server.rb
|
63
|
+
- lib/websocket/nice_inspect.rb
|
118
64
|
- lib/websocket/version.rb
|
119
65
|
- spec/frame/incoming_03_spec.rb
|
120
66
|
- spec/frame/incoming_04_spec.rb
|
@@ -157,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
103
|
requirements:
|
158
104
|
- - ">="
|
159
105
|
- !ruby/object:Gem::Version
|
160
|
-
version: '0'
|
106
|
+
version: '2.0'
|
161
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
108
|
requirements:
|
163
109
|
- - ">="
|
@@ -165,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
111
|
version: '0'
|
166
112
|
requirements: []
|
167
113
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.14
|
169
115
|
signing_key:
|
170
116
|
specification_version: 4
|
171
117
|
summary: Universal Ruby library to handle WebSocket protocol
|