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 +4 -4
- data/.travis.yml +5 -3
- data/CHANGELOG.md +4 -0
- data/lib/websocket/frame/handler/handler05.rb +0 -8
- data/lib/websocket/frame/handler/handler07.rb +22 -0
- data/lib/websocket/version.rb +1 -1
- data/spec/frame/incoming_07_spec.rb +2 -1
- data/spec/frame/outgoing_07_spec.rb +14 -3
- data/spec/support/incoming_frames.rb +1 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd819fd576b9bc42e42b888bf9407c20e1557d62
|
4
|
+
data.tar.gz: b5a0b3732a0058688c3d2121833dd4909b5d9371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba657ffa0c0efe8cfbdca9fa5b229bb8aba86eda86a37eca0d7511695a42008e86c18ad8e89280773a97212ad1b08b3b811bdf9219974f1205c6effb1f9d5c90
|
7
|
+
data.tar.gz: 6ed217acb30fd88f14b7007a4df1e4534f7d0f01057c450ed463fe7cdaa94023d2de51ba8c373bc6f383e13e07bacecea731ee079d7102cc7b351d01c26f1049
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/websocket/version.rb
CHANGED
@@ -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\
|
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\
|
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'
|
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.
|
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:
|
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.
|
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
|