websocket_parser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -1
- data/lib/websocket/parser.rb +2 -2
- data/lib/websocket/version.rb +1 -1
- data/lib/websocket_parser.rb +2 -2
- data/spec/websocket/message_spec.rb +1 -1
- data/spec/websocket/parser_spec.rb +2 -2
- metadata +30 -29
data/Gemfile
CHANGED
data/lib/websocket/parser.rb
CHANGED
@@ -113,11 +113,11 @@ module WebSocket
|
|
113
113
|
|
114
114
|
def read_extended_payload_length
|
115
115
|
if message_size == :medium && @data.size >= 2
|
116
|
-
size = unpack_bytes(2,'S
|
116
|
+
size = unpack_bytes(2,'S>')
|
117
117
|
ParserError.new("Wrong payload length. Expected to be greater than 125") unless size > 125
|
118
118
|
size
|
119
119
|
elsif message_size == :large && @data.size >= 4
|
120
|
-
size = unpack_bytes(8,'Q
|
120
|
+
size = unpack_bytes(8,'Q>')
|
121
121
|
ParserError.new("Wrong payload length. Expected to be greater than 65535") unless size > 65_535
|
122
122
|
size
|
123
123
|
end
|
data/lib/websocket/version.rb
CHANGED
data/lib/websocket_parser.rb
CHANGED
@@ -10,7 +10,7 @@ describe WebSocket::Message do
|
|
10
10
|
# 2 bytes from header + 8 bytes from extended payload length + payload
|
11
11
|
data.size.should == 2 + 8 + text.length
|
12
12
|
|
13
|
-
first_byte, second_byte, ext_length, payload = data.unpack("CCQ
|
13
|
+
first_byte, second_byte, ext_length, payload = data.unpack("CCQ>a#{text.length}")
|
14
14
|
|
15
15
|
first_byte.should == 0b10000001 # Text frame with FIN bit set
|
16
16
|
second_byte.should == 0b01111111 # Unmasked. Payload length 127.
|
@@ -168,14 +168,14 @@ describe WebSocket::Parser do
|
|
168
168
|
|
169
169
|
it "recognizes 256 bytes binary message in a single unmasked frame" do
|
170
170
|
data = Array.new(256) { rand(256) }.pack('c*')
|
171
|
-
parser << [0x82, 0x7E, 0x0100].pack('CCS
|
171
|
+
parser << [0x82, 0x7E, 0x0100].pack('CCS>') + data
|
172
172
|
|
173
173
|
received_messages.first.should == data
|
174
174
|
end
|
175
175
|
|
176
176
|
it "recoginzes 64KiB binary message in a single unmasked frame" do
|
177
177
|
data = Array.new(65536) { rand(256) }.pack('c*')
|
178
|
-
parser << [0x82, 0x7F, 0x0000000000010000].pack('CCQ
|
178
|
+
parser << [0x82, 0x7F, 0x0000000000010000].pack('CCQ>') + data
|
179
179
|
|
180
180
|
received_messages.first.should == data
|
181
181
|
end
|
metadata
CHANGED
@@ -1,64 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: websocket_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alberto Fernandez-Capel
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
16
|
-
|
17
|
-
none: false
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
17
|
requirements:
|
19
18
|
- - ! '>='
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
21
|
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
|
-
|
33
|
-
none: false
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
33
|
requirements:
|
35
34
|
- - ! '>='
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
42
39
|
requirements:
|
43
40
|
- - ! '>='
|
44
41
|
- !ruby/object:Gem::Version
|
45
42
|
version: '0'
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :development
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rspec
|
48
|
-
|
49
|
-
none: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
50
|
- - ! '>='
|
52
51
|
- !ruby/object:Gem::Version
|
53
52
|
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
53
|
none: false
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
58
55
|
requirements:
|
59
56
|
- - ! '>='
|
60
57
|
- !ruby/object:Gem::Version
|
61
58
|
version: '0'
|
59
|
+
none: false
|
60
|
+
prerelease: false
|
61
|
+
type: :development
|
62
62
|
description: WebsocketParser is a RFC6455 compliant parser for websocket messages
|
63
63
|
email:
|
64
64
|
- afcapel@gmail.com
|
@@ -85,32 +85,32 @@ files:
|
|
85
85
|
- websocket_parser.gemspec
|
86
86
|
homepage: http://github.com/afcapel/websocket_parser
|
87
87
|
licenses: []
|
88
|
-
post_install_message:
|
88
|
+
post_install_message:
|
89
89
|
rdoc_options: []
|
90
90
|
require_paths:
|
91
91
|
- lib
|
92
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
93
|
requirements:
|
95
94
|
- - ! '>='
|
96
95
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
96
|
segments:
|
99
97
|
- 0
|
100
|
-
hash:
|
101
|
-
|
98
|
+
hash: 2
|
99
|
+
version: '0'
|
102
100
|
none: false
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
102
|
requirements:
|
104
103
|
- - ! '>='
|
105
104
|
- !ruby/object:Gem::Version
|
106
|
-
version: '0'
|
107
105
|
segments:
|
108
106
|
- 0
|
109
|
-
hash:
|
107
|
+
hash: 2
|
108
|
+
version: '0'
|
109
|
+
none: false
|
110
110
|
requirements: []
|
111
|
-
rubyforge_project:
|
112
|
-
rubygems_version: 1.8.
|
113
|
-
signing_key:
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.8.24
|
113
|
+
signing_key:
|
114
114
|
specification_version: 3
|
115
115
|
summary: Parse websockets messages in Ruby
|
116
116
|
test_files:
|
@@ -118,3 +118,4 @@ test_files:
|
|
118
118
|
- spec/websocket/handshake_spec.rb
|
119
119
|
- spec/websocket/message_spec.rb
|
120
120
|
- spec/websocket/parser_spec.rb
|
121
|
+
...
|