websocket 1.1.2 → 1.1.3

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: 867a294ded953698c44e679d6de8764c5da9c98a
4
- data.tar.gz: a2eb7f03a1bf0881e5a13968eaec06a7b8ab81c7
3
+ metadata.gz: dd819fd576b9bc42e42b888bf9407c20e1557d62
4
+ data.tar.gz: b5a0b3732a0058688c3d2121833dd4909b5d9371
5
5
  SHA512:
6
- metadata.gz: fa5d680161502ea411f19ec76af3629db2d20dbd3929348c02ad8c96b62aef78bf7b4f5080a9512da104f237c7efeff55e551a48b626d4443ae58d28a5579143
7
- data.tar.gz: 8e3c61c2b533bea813f5320f09daf394824412808d7c4052ab0f68c228a43bd2e7dfa0187a0fe07632f96098f9eb15906c7028ac2fcc06217d0764922978215e
6
+ metadata.gz: ba657ffa0c0efe8cfbdca9fa5b229bb8aba86eda86a37eca0d7511695a42008e86c18ad8e89280773a97212ad1b08b3b811bdf9219974f1205c6effb1f9d5c90
7
+ data.tar.gz: 6ed217acb30fd88f14b7007a4df1e4534f7d0f01057c450ed463fe7cdaa94023d2de51ba8c373bc6f383e13e07bacecea731ee079d7102cc7b351d01c26f1049
data/.travis.yml CHANGED
@@ -5,8 +5,10 @@ rvm:
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0.0
8
+ - 2.1.1
9
+ - ree
10
+ - rbx
8
11
  - jruby-18mode
9
12
  - jruby-19mode
10
- - rbx-18mode
11
- - rbx-19mode
12
- - ree
13
+ - ruby-head
14
+ - jruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.3
4
+
5
+ - fix close code support
6
+
3
7
  ## 1.1.2
4
8
 
5
9
  - fix support for rack input that is blocking (i.e. Passenger)
@@ -5,14 +5,6 @@ module WebSocket
5
5
  module Handler
6
6
  class Handler05 < Handler04
7
7
 
8
- def encode_frame
9
- if @frame.code
10
- @frame.data = Data.new([@frame.code].pack('n') + @frame.data.to_s)
11
- @frame.code = nil
12
- end
13
- super
14
- end
15
-
16
8
  # Since handler 5 masking should be enabled by default
17
9
  def masking?; true; end
18
10
 
@@ -18,8 +18,30 @@ module WebSocket
18
18
  # Hash of frame opcodes and it's names
19
19
  FRAME_TYPES_INVERSE = FRAME_TYPES.invert
20
20
 
21
+ def encode_frame
22
+ if @frame.type == :close
23
+ code = @frame.code || 1000
24
+ @frame.data = Data.new([code].pack('n') + @frame.data.to_s)
25
+ @frame.code = nil
26
+ end
27
+ super
28
+ end
29
+
30
+ def decode_frame
31
+ result = super
32
+ if has_close_code?(result)
33
+ code = result.data.slice!(0..1)
34
+ result.code = code.unpack('n').first
35
+ end
36
+ result
37
+ end
38
+
21
39
  private
22
40
 
41
+ def has_close_code?(frame)
42
+ frame && frame.type == :close && !frame.data.empty?
43
+ end
44
+
23
45
  # Convert frame type name to opcode
24
46
  # @param [Symbol] frame_type Frame type name
25
47
  # @return [Integer] opcode or nil
@@ -1,3 +1,3 @@
1
1
  module WebSocket
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
@@ -13,9 +13,10 @@ describe 'Incoming frame draft 07' do
13
13
  it_should_behave_like 'valid_incoming_frame'
14
14
 
15
15
  context "should properly decode close frame" do
16
- let(:encoded_text) { "\x88\x05" + decoded_text }
16
+ let(:encoded_text) { "\x88\x07\x03\xE8" + decoded_text }
17
17
  let(:frame_type) { :close }
18
18
  let(:decoded_text) { "Hello" }
19
+ let(:close_code) { 1000 }
19
20
 
20
21
  it_should_behave_like 'valid_incoming_frame'
21
22
  end
@@ -3,8 +3,9 @@ require 'spec_helper'
3
3
 
4
4
  describe 'Outgoing frame draft 07' do
5
5
  let(:version) { 7 }
6
- let(:frame) { WebSocket::Frame::Outgoing.new(:version => version, :data => decoded_text, :type => frame_type) }
6
+ let(:frame) { WebSocket::Frame::Outgoing.new(:version => version, :data => decoded_text, :type => frame_type, :code => close_code) }
7
7
  let(:decoded_text) { "" }
8
+ let(:close_code) { nil }
8
9
  let(:encoded_text) { "\x81\x00" }
9
10
  let(:frame_type) { :text }
10
11
  let(:require_sending) { true }
@@ -13,10 +14,20 @@ describe 'Outgoing frame draft 07' do
13
14
 
14
15
  it_should_behave_like 'valid_outgoing_frame'
15
16
 
16
- context "should properly encode close frame" do
17
+ context "should properly encode close frame without close code" do
17
18
  let(:frame_type) { :close }
18
19
  let(:decoded_text) { "Hello" }
19
- let(:encoded_text) { "\x88\x05" + decoded_text }
20
+ let(:encoded_text) { "\x88\x07\x03\xE8" + decoded_text }
21
+ let(:require_sending) { true }
22
+
23
+ it_should_behave_like 'valid_outgoing_frame'
24
+ end
25
+
26
+ context "should properly encode close frame with close code" do
27
+ let(:frame_type) { :close }
28
+ let(:decoded_text) { "Hello" }
29
+ let(:close_code) { 1001 }
30
+ let(:encoded_text) { "\x88\x07\x03\xE9" + decoded_text }
20
31
  let(:require_sending) { true }
21
32
 
22
33
  it_should_behave_like 'valid_outgoing_frame'
@@ -28,6 +28,7 @@ shared_examples_for 'valid_incoming_frame' do
28
28
  f = subject.next
29
29
  f.decoded?.should be_true
30
30
  f.type.should eql(frame_type_array[index])
31
+ f.code.should eql(close_code) if defined?(close_code)
31
32
  f.to_s.should eql(da)
32
33
  end
33
34
  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.1.2
4
+ version: 1.1.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: 2013-11-13 00:00:00.000000000 Z
11
+ date: 2014-05-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Universal Ruby library to handle WebSocket protocol
14
14
  email:
@@ -17,8 +17,8 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
21
- - .travis.yml
20
+ - ".gitignore"
21
+ - ".travis.yml"
22
22
  - CHANGELOG.md
23
23
  - Gemfile
24
24
  - README.md
@@ -95,17 +95,17 @@ require_paths:
95
95
  - lib
96
96
  required_ruby_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - '>='
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.1.9
108
+ rubygems_version: 2.2.2
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Universal Ruby library to handle WebSocket protocol