websocket 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +37 -0
  3. data/.travis.yml +2 -0
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile +1 -1
  6. data/Rakefile +3 -3
  7. data/lib/websocket.rb +2 -3
  8. data/lib/websocket/error.rb +57 -25
  9. data/lib/websocket/exception_handler.rb +2 -14
  10. data/lib/websocket/frame.rb +0 -2
  11. data/lib/websocket/frame/base.rb +12 -13
  12. data/lib/websocket/frame/data.rb +1 -3
  13. data/lib/websocket/frame/handler.rb +0 -2
  14. data/lib/websocket/frame/handler/base.rb +2 -4
  15. data/lib/websocket/frame/handler/handler03.rb +149 -112
  16. data/lib/websocket/frame/handler/handler04.rb +3 -3
  17. data/lib/websocket/frame/handler/handler05.rb +3 -3
  18. data/lib/websocket/frame/handler/handler07.rb +8 -10
  19. data/lib/websocket/frame/handler/handler75.rb +10 -12
  20. data/lib/websocket/frame/incoming.rb +0 -2
  21. data/lib/websocket/frame/incoming/client.rb +0 -2
  22. data/lib/websocket/frame/incoming/server.rb +0 -2
  23. data/lib/websocket/frame/outgoing.rb +1 -3
  24. data/lib/websocket/frame/outgoing/client.rb +0 -2
  25. data/lib/websocket/frame/outgoing/server.rb +0 -2
  26. data/lib/websocket/handshake.rb +0 -2
  27. data/lib/websocket/handshake/base.rb +10 -9
  28. data/lib/websocket/handshake/client.rb +22 -35
  29. data/lib/websocket/handshake/handler.rb +0 -2
  30. data/lib/websocket/handshake/handler/base.rb +0 -2
  31. data/lib/websocket/handshake/handler/client.rb +0 -2
  32. data/lib/websocket/handshake/handler/client01.rb +0 -2
  33. data/lib/websocket/handshake/handler/client04.rb +3 -5
  34. data/lib/websocket/handshake/handler/client11.rb +0 -2
  35. data/lib/websocket/handshake/handler/client75.rb +2 -4
  36. data/lib/websocket/handshake/handler/client76.rb +6 -8
  37. data/lib/websocket/handshake/handler/server.rb +0 -1
  38. data/lib/websocket/handshake/handler/server04.rb +3 -5
  39. data/lib/websocket/handshake/handler/server75.rb +2 -4
  40. data/lib/websocket/handshake/handler/server76.rb +7 -9
  41. data/lib/websocket/handshake/server.rb +19 -24
  42. data/lib/websocket/version.rb +1 -1
  43. data/spec/frame/incoming_03_spec.rb +1 -2
  44. data/spec/frame/incoming_04_spec.rb +1 -2
  45. data/spec/frame/incoming_05_spec.rb +1 -2
  46. data/spec/frame/incoming_07_spec.rb +1 -2
  47. data/spec/frame/incoming_75_spec.rb +1 -2
  48. data/spec/support/all_client_drafts.rb +1 -1
  49. data/spec/support/all_server_drafts.rb +7 -10
  50. data/spec/support/frames_base.rb +0 -2
  51. data/spec/support/handshake_requests.rb +4 -4
  52. data/spec/support/outgoing_frames.rb +0 -1
  53. data/spec/support/overwrites.rb +0 -2
  54. data/websocket.gemspec +10 -10
  55. 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) { ['abc', 'def'] }
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({ 'aaa' => 'bbb' })
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 = client_request.slice((request.to_s.length..-1))
90
+ rest = client_request.slice((request.to_s.length..-1))
91
91
 
92
92
  handshake.from_rack(request.meta_vars.merge(
93
- 'rack.input' => StringIO.new(rest)
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.reduce({}) do |hash, 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
- headers: headers,
112
- path: path,
113
- query: query,
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
@@ -1,7 +1,6 @@
1
1
  module WebSocket
2
2
  module Frame
3
3
  class Base
4
-
5
4
  def incoming_masking?
6
5
  @handler.masking?
7
6
  end
@@ -9,7 +8,6 @@ module WebSocket
9
8
  def outgoing_masking?
10
9
  false
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -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
@@ -10,5 +10,4 @@ RSpec.shared_examples_for 'valid_outgoing_frame' do
10
10
  its(:error) { is_expected.to eql(error) }
11
11
  its(:require_sending?) { is_expected.to eql(require_sending) }
12
12
  end
13
-
14
13
  end
@@ -1,9 +1,7 @@
1
1
  module WebSocket
2
-
3
2
  module Handshake
4
3
  class Base
5
4
  attr_reader :handler
6
5
  end
7
6
  end
8
-
9
7
  end
@@ -1,20 +1,20 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "websocket/version"
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 = "websocket"
6
+ s.name = 'websocket'
7
7
  s.version = WebSocket::VERSION
8
8
  s.platform = Gem::Platform::RUBY
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"
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 = ["lib"]
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.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: 2015-04-17 00:00:00.000000000 Z
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.4.5
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