websocket 1.1.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -6
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -1
- data/README.md +10 -6
- data/Rakefile +1 -1
- data/lib/websocket.rb +1 -1
- data/lib/websocket/exception_handler.rb +6 -0
- data/lib/websocket/frame/base.rb +1 -1
- data/lib/websocket/frame/data.rb +11 -9
- data/lib/websocket/frame/handler.rb +1 -1
- data/lib/websocket/frame/handler/handler03.rb +17 -17
- data/lib/websocket/frame/handler/handler07.rb +8 -8
- data/lib/websocket/frame/handler/handler75.rb +8 -7
- data/lib/websocket/frame/incoming.rb +1 -1
- data/lib/websocket/frame/outgoing.rb +1 -1
- data/lib/websocket/handshake/base.rb +7 -7
- data/lib/websocket/handshake/client.rb +5 -3
- data/lib/websocket/handshake/handler/base.rb +5 -5
- data/lib/websocket/handshake/handler/client.rb +6 -1
- data/lib/websocket/handshake/handler/client04.rb +7 -6
- data/lib/websocket/handshake/handler/client75.rb +5 -4
- data/lib/websocket/handshake/handler/client76.rb +5 -5
- data/lib/websocket/handshake/handler/server04.rb +11 -6
- data/lib/websocket/handshake/handler/server75.rb +5 -5
- data/lib/websocket/handshake/handler/server76.rb +9 -9
- data/lib/websocket/handshake/server.rb +25 -24
- data/lib/websocket/version.rb +1 -1
- data/spec/frame/incoming_03_spec.rb +25 -25
- data/spec/frame/incoming_04_spec.rb +25 -25
- data/spec/frame/incoming_05_spec.rb +29 -29
- data/spec/frame/incoming_07_spec.rb +31 -31
- data/spec/frame/incoming_75_spec.rb +13 -13
- data/spec/frame/incoming_common_spec.rb +12 -13
- data/spec/frame/masking_spec.rb +10 -10
- data/spec/frame/outgoing_03_spec.rb +17 -17
- data/spec/frame/outgoing_04_spec.rb +17 -17
- data/spec/frame/outgoing_05_spec.rb +17 -17
- data/spec/frame/outgoing_07_spec.rb +19 -19
- data/spec/frame/outgoing_75_spec.rb +9 -9
- data/spec/frame/outgoing_common_spec.rb +7 -8
- data/spec/handshake/client_04_spec.rb +9 -9
- data/spec/handshake/client_75_spec.rb +2 -2
- data/spec/handshake/client_76_spec.rb +9 -9
- data/spec/handshake/server_04_spec.rb +5 -5
- data/spec/handshake/server_75_spec.rb +1 -1
- data/spec/handshake/server_76_spec.rb +21 -21
- data/spec/spec_helper.rb +4 -1
- data/spec/support/all_client_drafts.rb +62 -52
- data/spec/support/all_server_drafts.rb +49 -49
- data/spec/support/handshake_requests.rb +16 -16
- data/spec/support/incoming_frames.rb +28 -28
- data/spec/support/outgoing_frames.rb +10 -10
- data/websocket.gemspec +1 -1
- metadata +42 -22
- checksums.yaml +0 -7
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: binary
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'Incoming frame draft 04' do
|
4
|
+
RSpec.describe 'Incoming frame draft 04' do
|
5
5
|
let(:version) { 4 }
|
6
|
-
let(:frame) { WebSocket::Frame::Incoming.new(:
|
6
|
+
let(:frame) { WebSocket::Frame::Incoming.new(version: version, data: encoded_text) }
|
7
7
|
let(:encoded_text) { nil }
|
8
8
|
let(:decoded_text) { nil }
|
9
9
|
let(:frame_type) { nil }
|
@@ -12,86 +12,86 @@ describe 'Incoming frame draft 04' do
|
|
12
12
|
|
13
13
|
it_should_behave_like 'valid_incoming_frame'
|
14
14
|
|
15
|
-
context
|
15
|
+
context 'should properly decode close frame' do
|
16
16
|
let(:encoded_text) { "\x81\x05" + decoded_text }
|
17
17
|
let(:frame_type) { :close }
|
18
|
-
let(:decoded_text) {
|
18
|
+
let(:decoded_text) { 'Hello' }
|
19
19
|
|
20
20
|
it_should_behave_like 'valid_incoming_frame'
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
23
|
+
context 'should properly decode ping frame' do
|
24
24
|
let(:encoded_text) { "\x82\x05" + decoded_text }
|
25
25
|
let(:frame_type) { :ping }
|
26
|
-
let(:decoded_text) {
|
26
|
+
let(:decoded_text) { 'Hello' }
|
27
27
|
|
28
28
|
it_should_behave_like 'valid_incoming_frame'
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
31
|
+
context 'should properly decode pong frame' do
|
32
32
|
let(:encoded_text) { "\x83\x05" + decoded_text }
|
33
33
|
let(:frame_type) { :pong }
|
34
|
-
let(:decoded_text) {
|
34
|
+
let(:decoded_text) { 'Hello' }
|
35
35
|
|
36
36
|
it_should_behave_like 'valid_incoming_frame'
|
37
37
|
end
|
38
38
|
|
39
|
-
context
|
39
|
+
context 'should properly decode text frame' do
|
40
40
|
let(:encoded_text) { "\x84\x05" + decoded_text }
|
41
|
-
let(:decoded_text) {
|
41
|
+
let(:decoded_text) { 'Hello' }
|
42
42
|
let(:frame_type) { :text }
|
43
43
|
|
44
44
|
it_should_behave_like 'valid_incoming_frame'
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
47
|
+
context 'should properly decode text frame with continuation' do
|
48
48
|
let(:encoded_text) { "\x04\x03Hel\x80\x02lo" }
|
49
49
|
let(:frame_type) { :text }
|
50
|
-
let(:decoded_text) {
|
50
|
+
let(:decoded_text) { 'Hello' }
|
51
51
|
|
52
52
|
it_should_behave_like 'valid_incoming_frame'
|
53
53
|
end
|
54
54
|
|
55
|
-
context
|
55
|
+
context 'should properly decode text frame in between of continuation' do
|
56
56
|
let(:encoded_text) { "\x04\x03Hel\x83\x03abc\x80\x02lo" }
|
57
57
|
let(:frame_type) { [:pong, :text] }
|
58
|
-
let(:decoded_text) { [
|
58
|
+
let(:decoded_text) { ['abc', 'Hello'] }
|
59
59
|
|
60
60
|
it_should_behave_like 'valid_incoming_frame'
|
61
61
|
end
|
62
62
|
|
63
|
-
context
|
63
|
+
context 'should not return unfinished more frame' do
|
64
64
|
let(:encoded_text) { "\x04\x03Hel\x83\x03abc" }
|
65
65
|
let(:frame_type) { :pong }
|
66
|
-
let(:decoded_text) {
|
66
|
+
let(:decoded_text) { 'abc' }
|
67
67
|
|
68
68
|
it_should_behave_like 'valid_incoming_frame'
|
69
69
|
end
|
70
70
|
|
71
|
-
context
|
71
|
+
context 'should properly decode 256 bytes binary frame' do
|
72
72
|
let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
|
73
73
|
let(:frame_type) { :binary }
|
74
|
-
let(:decoded_text) {
|
74
|
+
let(:decoded_text) { 'a' * 256 }
|
75
75
|
|
76
76
|
it_should_behave_like 'valid_incoming_frame'
|
77
77
|
end
|
78
78
|
|
79
|
-
context
|
79
|
+
context 'should properly decode 64KiB binary frame' do
|
80
80
|
let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
|
81
81
|
let(:frame_type) { :binary }
|
82
|
-
let(:decoded_text) {
|
82
|
+
let(:decoded_text) { 'a' * 65_536 }
|
83
83
|
|
84
84
|
it_should_behave_like 'valid_incoming_frame'
|
85
85
|
end
|
86
86
|
|
87
|
-
context
|
87
|
+
context 'should wait with incomplete frame' do
|
88
88
|
let(:encoded_text) { "\x84\x06Hello" }
|
89
89
|
let(:decoded_text) { nil }
|
90
90
|
|
91
91
|
it_should_behave_like 'valid_incoming_frame'
|
92
92
|
end
|
93
93
|
|
94
|
-
context
|
94
|
+
context 'should raise error with invalid opcode' do
|
95
95
|
let(:encoded_text) { "\x89\x05Hello" }
|
96
96
|
let(:decoded_text) { nil }
|
97
97
|
let(:error) { WebSocket::Error::Frame::UnknownOpcode }
|
@@ -99,15 +99,15 @@ describe 'Incoming frame draft 04' do
|
|
99
99
|
it_should_behave_like 'valid_incoming_frame'
|
100
100
|
end
|
101
101
|
|
102
|
-
context
|
103
|
-
let(:encoded_text) { "\x84\x7F" +
|
102
|
+
context 'should raise error with too long frame' do
|
103
|
+
let(:encoded_text) { "\x84\x7F" + 'a' * WebSocket.max_frame_size }
|
104
104
|
let(:decoded_text) { nil }
|
105
105
|
let(:error) { WebSocket::Error::Frame::TooLong }
|
106
106
|
|
107
107
|
it_should_behave_like 'valid_incoming_frame'
|
108
108
|
end
|
109
109
|
|
110
|
-
context
|
110
|
+
context 'should raise error with continuation frame without more frame earlier' do
|
111
111
|
let(:encoded_text) { "\x80\x05Hello" }
|
112
112
|
let(:decoded_text) { nil }
|
113
113
|
let(:error) { WebSocket::Error::Frame::UnexpectedContinuationFrame }
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: binary
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'Incoming frame draft 05' do
|
4
|
+
RSpec.describe 'Incoming frame draft 05' do
|
5
5
|
let(:version) { 5 }
|
6
|
-
let(:frame) { WebSocket::Frame::Incoming.new(:
|
6
|
+
let(:frame) { WebSocket::Frame::Incoming.new(version: version, data: encoded_text) }
|
7
7
|
let(:encoded_text) { nil }
|
8
8
|
let(:decoded_text) { nil }
|
9
9
|
let(:frame_type) { nil }
|
@@ -12,102 +12,102 @@ describe 'Incoming frame draft 05' do
|
|
12
12
|
|
13
13
|
it_should_behave_like 'valid_incoming_frame'
|
14
14
|
|
15
|
-
context
|
15
|
+
context 'should properly decode close frame' do
|
16
16
|
let(:encoded_text) { "\x81\x05" + decoded_text }
|
17
17
|
let(:frame_type) { :close }
|
18
|
-
let(:decoded_text) {
|
18
|
+
let(:decoded_text) { 'Hello' }
|
19
19
|
|
20
20
|
it_should_behave_like 'valid_incoming_frame'
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
23
|
+
context 'should properly decode ping frame' do
|
24
24
|
let(:encoded_text) { "\x82\x05" + decoded_text }
|
25
25
|
let(:frame_type) { :ping }
|
26
|
-
let(:decoded_text) {
|
26
|
+
let(:decoded_text) { 'Hello' }
|
27
27
|
|
28
28
|
it_should_behave_like 'valid_incoming_frame'
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
31
|
+
context 'should properly decode pong frame' do
|
32
32
|
let(:encoded_text) { "\x83\x05" + decoded_text }
|
33
33
|
let(:frame_type) { :pong }
|
34
|
-
let(:decoded_text) {
|
34
|
+
let(:decoded_text) { 'Hello' }
|
35
35
|
|
36
36
|
it_should_behave_like 'valid_incoming_frame'
|
37
37
|
end
|
38
38
|
|
39
|
-
context
|
39
|
+
context 'should properly decode text frame' do
|
40
40
|
let(:encoded_text) { "\x84\x05" + decoded_text }
|
41
|
-
let(:decoded_text) {
|
41
|
+
let(:decoded_text) { 'Hello' }
|
42
42
|
let(:frame_type) { :text }
|
43
43
|
|
44
44
|
it_should_behave_like 'valid_incoming_frame'
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
47
|
+
context 'should properly decode masked text frame' do
|
48
48
|
let(:encoded_text) { "\x84\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58" }
|
49
|
-
let(:decoded_text) {
|
49
|
+
let(:decoded_text) { 'Hello' }
|
50
50
|
let(:frame_type) { :text }
|
51
51
|
|
52
52
|
it_should_behave_like 'valid_incoming_frame'
|
53
53
|
end
|
54
54
|
|
55
|
-
context
|
55
|
+
context 'should properly decode text frame with continuation' do
|
56
56
|
let(:encoded_text) { "\x04\x03Hel\x80\x02lo" }
|
57
57
|
let(:frame_type) { :text }
|
58
|
-
let(:decoded_text) {
|
58
|
+
let(:decoded_text) { 'Hello' }
|
59
59
|
|
60
60
|
it_should_behave_like 'valid_incoming_frame'
|
61
61
|
end
|
62
62
|
|
63
|
-
context
|
63
|
+
context 'should properly decode masked text frame with continuation' do
|
64
64
|
let(:encoded_text) { "\x04\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x37\xfa\x21\x3d\x5b\x95" }
|
65
65
|
let(:frame_type) { :text }
|
66
|
-
let(:decoded_text) {
|
66
|
+
let(:decoded_text) { 'Hello' }
|
67
67
|
|
68
68
|
it_should_behave_like 'valid_incoming_frame'
|
69
69
|
end
|
70
70
|
|
71
|
-
context
|
71
|
+
context 'should properly decode text frame in between of continuation' do
|
72
72
|
let(:encoded_text) { "\x04\x03Hel\x83\x03abc\x80\x02lo" }
|
73
73
|
let(:frame_type) { [:pong, :text] }
|
74
|
-
let(:decoded_text) { [
|
74
|
+
let(:decoded_text) { ['abc', 'Hello'] }
|
75
75
|
|
76
76
|
it_should_behave_like 'valid_incoming_frame'
|
77
77
|
end
|
78
78
|
|
79
|
-
context
|
79
|
+
context 'should not return unfinished more frame' do
|
80
80
|
let(:encoded_text) { "\x04\x03Hel\x83\x03abc" }
|
81
81
|
let(:frame_type) { :pong }
|
82
|
-
let(:decoded_text) {
|
82
|
+
let(:decoded_text) { 'abc' }
|
83
83
|
|
84
84
|
it_should_behave_like 'valid_incoming_frame'
|
85
85
|
end
|
86
86
|
|
87
|
-
context
|
87
|
+
context 'should properly decode 256 bytes binary frame' do
|
88
88
|
let(:encoded_text) { "\x85\x7E\x01\x00" + decoded_text }
|
89
89
|
let(:frame_type) { :binary }
|
90
|
-
let(:decoded_text) {
|
90
|
+
let(:decoded_text) { 'a' * 256 }
|
91
91
|
|
92
92
|
it_should_behave_like 'valid_incoming_frame'
|
93
93
|
end
|
94
94
|
|
95
|
-
context
|
95
|
+
context 'should properly decode 64KiB binary frame' do
|
96
96
|
let(:encoded_text) { "\x85\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
|
97
97
|
let(:frame_type) { :binary }
|
98
|
-
let(:decoded_text) {
|
98
|
+
let(:decoded_text) { 'a' * 65_536 }
|
99
99
|
|
100
100
|
it_should_behave_like 'valid_incoming_frame'
|
101
101
|
end
|
102
102
|
|
103
|
-
context
|
103
|
+
context 'should wait with incomplete frame' do
|
104
104
|
let(:encoded_text) { "\x84\x06Hello" }
|
105
105
|
let(:decoded_text) { nil }
|
106
106
|
|
107
107
|
it_should_behave_like 'valid_incoming_frame'
|
108
108
|
end
|
109
109
|
|
110
|
-
context
|
110
|
+
context 'should raise error with invalid opcode' do
|
111
111
|
let(:encoded_text) { "\x89\x05Hello" }
|
112
112
|
let(:decoded_text) { nil }
|
113
113
|
let(:error) { WebSocket::Error::Frame::UnknownOpcode }
|
@@ -115,15 +115,15 @@ describe 'Incoming frame draft 05' do
|
|
115
115
|
it_should_behave_like 'valid_incoming_frame'
|
116
116
|
end
|
117
117
|
|
118
|
-
context
|
119
|
-
let(:encoded_text) { "\x84\x7F" +
|
118
|
+
context 'should raise error with too long frame' do
|
119
|
+
let(:encoded_text) { "\x84\x7F" + 'a' * WebSocket.max_frame_size }
|
120
120
|
let(:decoded_text) { nil }
|
121
121
|
let(:error) { WebSocket::Error::Frame::TooLong }
|
122
122
|
|
123
123
|
it_should_behave_like 'valid_incoming_frame'
|
124
124
|
end
|
125
125
|
|
126
|
-
context
|
126
|
+
context 'should raise error with continuation frame without more frame earlier' do
|
127
127
|
let(:encoded_text) { "\x80\x05Hello" }
|
128
128
|
let(:decoded_text) { nil }
|
129
129
|
let(:error) { WebSocket::Error::Frame::UnexpectedContinuationFrame }
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: binary
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'Incoming frame draft 07' do
|
4
|
+
RSpec.describe 'Incoming frame draft 07' do
|
5
5
|
let(:version) { 7 }
|
6
|
-
let(:frame) { WebSocket::Frame::Incoming.new(:
|
6
|
+
let(:frame) { WebSocket::Frame::Incoming.new(version: version, data: encoded_text) }
|
7
7
|
let(:encoded_text) { nil }
|
8
8
|
let(:decoded_text) { nil }
|
9
9
|
let(:frame_type) { nil }
|
@@ -12,16 +12,16 @@ describe 'Incoming frame draft 07' do
|
|
12
12
|
|
13
13
|
it_should_behave_like 'valid_incoming_frame'
|
14
14
|
|
15
|
-
context
|
15
|
+
context 'should properly decode close frame' do
|
16
16
|
let(:encoded_text) { "\x88\x07\x03\xE8" + decoded_text }
|
17
17
|
let(:frame_type) { :close }
|
18
|
-
let(:decoded_text) {
|
18
|
+
let(:decoded_text) { 'Hello' }
|
19
19
|
let(:close_code) { 1000 }
|
20
20
|
|
21
21
|
it_should_behave_like 'valid_incoming_frame'
|
22
22
|
end
|
23
23
|
|
24
|
-
context
|
24
|
+
context 'should raise error with invalid close code' do
|
25
25
|
let(:encoded_text) { "\x88\x07\x03\xEDHello" }
|
26
26
|
let(:decoded_text) { nil }
|
27
27
|
let(:error) { WebSocket::Error::Frame::UnknownCloseCode }
|
@@ -29,7 +29,7 @@ describe 'Incoming frame draft 07' do
|
|
29
29
|
it_should_behave_like 'valid_incoming_frame'
|
30
30
|
end
|
31
31
|
|
32
|
-
context
|
32
|
+
context 'should properly decode close frame with invalid UTF-8 message' do
|
33
33
|
let(:encoded_text) { "\x88\x03\x03\xE8\xE3" }
|
34
34
|
let(:decoded_text) { nil }
|
35
35
|
let(:error) { WebSocket::Error::Frame::InvalidPayloadEncoding }
|
@@ -37,94 +37,94 @@ describe 'Incoming frame draft 07' do
|
|
37
37
|
it_should_behave_like 'valid_incoming_frame'
|
38
38
|
end
|
39
39
|
|
40
|
-
context
|
40
|
+
context 'should properly decode ping frame' do
|
41
41
|
let(:encoded_text) { "\x89\x05" + decoded_text }
|
42
42
|
let(:frame_type) { :ping }
|
43
|
-
let(:decoded_text) {
|
43
|
+
let(:decoded_text) { 'Hello' }
|
44
44
|
|
45
45
|
it_should_behave_like 'valid_incoming_frame'
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
48
|
+
context 'should properly decode pong frame' do
|
49
49
|
let(:encoded_text) { "\x8a\x05" + decoded_text }
|
50
50
|
let(:frame_type) { :pong }
|
51
|
-
let(:decoded_text) {
|
51
|
+
let(:decoded_text) { 'Hello' }
|
52
52
|
|
53
53
|
it_should_behave_like 'valid_incoming_frame'
|
54
54
|
end
|
55
55
|
|
56
|
-
context
|
56
|
+
context 'should properly decode text frame' do
|
57
57
|
let(:encoded_text) { "\x81\x05\x48\x65\x6c\x6c\x6f" }
|
58
|
-
let(:decoded_text) {
|
58
|
+
let(:decoded_text) { 'Hello' }
|
59
59
|
let(:frame_type) { :text }
|
60
60
|
|
61
61
|
it_should_behave_like 'valid_incoming_frame'
|
62
62
|
end
|
63
63
|
|
64
|
-
context
|
64
|
+
context 'should properly decode masked text frame' do
|
65
65
|
let(:encoded_text) { "\x81\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58" }
|
66
|
-
let(:decoded_text) {
|
66
|
+
let(:decoded_text) { 'Hello' }
|
67
67
|
let(:frame_type) { :text }
|
68
68
|
|
69
69
|
it_should_behave_like 'valid_incoming_frame'
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
72
|
+
context 'should properly decode text frame with continuation' do
|
73
73
|
let(:encoded_text) { "\x01\x03Hel\x80\x02lo" }
|
74
74
|
let(:frame_type) { :text }
|
75
|
-
let(:decoded_text) {
|
75
|
+
let(:decoded_text) { 'Hello' }
|
76
76
|
|
77
77
|
it_should_behave_like 'valid_incoming_frame'
|
78
78
|
end
|
79
79
|
|
80
|
-
context
|
80
|
+
context 'should properly decode masked text frame with continuation' do
|
81
81
|
let(:encoded_text) { "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x37\xfa\x21\x3d\x5b\x95" }
|
82
82
|
let(:frame_type) { :text }
|
83
|
-
let(:decoded_text) {
|
83
|
+
let(:decoded_text) { 'Hello' }
|
84
84
|
|
85
85
|
it_should_behave_like 'valid_incoming_frame'
|
86
86
|
end
|
87
87
|
|
88
|
-
context
|
88
|
+
context 'should properly decode text frame in between of continuation' do
|
89
89
|
let(:encoded_text) { "\x01\x03Hel\x8a\x03abc\x80\x02lo" }
|
90
90
|
let(:frame_type) { [:pong, :text] }
|
91
|
-
let(:decoded_text) { [
|
91
|
+
let(:decoded_text) { ['abc', 'Hello'] }
|
92
92
|
|
93
93
|
it_should_behave_like 'valid_incoming_frame'
|
94
94
|
end
|
95
95
|
|
96
|
-
context
|
96
|
+
context 'should not return unfinished more frame' do
|
97
97
|
let(:encoded_text) { "\x01\x03Hel\x8a\x03abc" }
|
98
98
|
let(:frame_type) { :pong }
|
99
|
-
let(:decoded_text) {
|
99
|
+
let(:decoded_text) { 'abc' }
|
100
100
|
|
101
101
|
it_should_behave_like 'valid_incoming_frame'
|
102
102
|
end
|
103
103
|
|
104
|
-
context
|
104
|
+
context 'should properly decode 256 bytes binary frame' do
|
105
105
|
let(:encoded_text) { "\x82\x7E\x01\x00" + decoded_text }
|
106
106
|
let(:frame_type) { :binary }
|
107
|
-
let(:decoded_text) {
|
107
|
+
let(:decoded_text) { 'a' * 256 }
|
108
108
|
|
109
109
|
it_should_behave_like 'valid_incoming_frame'
|
110
110
|
end
|
111
111
|
|
112
|
-
context
|
112
|
+
context 'should properly decode 64KiB binary frame' do
|
113
113
|
let(:encoded_text) { "\x82\x7F\x00\x00\x00\x00\x00\x01\x00\x00" + decoded_text }
|
114
114
|
let(:frame_type) { :binary }
|
115
|
-
let(:decoded_text) {
|
115
|
+
let(:decoded_text) { 'a' * 65_536 }
|
116
116
|
|
117
117
|
it_should_behave_like 'valid_incoming_frame'
|
118
118
|
end
|
119
119
|
|
120
|
-
context
|
120
|
+
context 'should wait with incomplete frame' do
|
121
121
|
let(:encoded_text) { "\x81\x06Hello" }
|
122
122
|
let(:decoded_text) { nil }
|
123
123
|
|
124
124
|
it_should_behave_like 'valid_incoming_frame'
|
125
125
|
end
|
126
126
|
|
127
|
-
context
|
127
|
+
context 'should raise error with invalid opcode' do
|
128
128
|
let(:encoded_text) { "\x85\x05Hello" }
|
129
129
|
let(:decoded_text) { nil }
|
130
130
|
let(:error) { WebSocket::Error::Frame::UnknownOpcode }
|
@@ -132,15 +132,15 @@ describe 'Incoming frame draft 07' do
|
|
132
132
|
it_should_behave_like 'valid_incoming_frame'
|
133
133
|
end
|
134
134
|
|
135
|
-
context
|
136
|
-
let(:encoded_text) { "\x81\x7F" +
|
135
|
+
context 'should raise error with too long frame' do
|
136
|
+
let(:encoded_text) { "\x81\x7F" + 'a' * WebSocket.max_frame_size }
|
137
137
|
let(:decoded_text) { nil }
|
138
138
|
let(:error) { WebSocket::Error::Frame::TooLong }
|
139
139
|
|
140
140
|
it_should_behave_like 'valid_incoming_frame'
|
141
141
|
end
|
142
142
|
|
143
|
-
context
|
143
|
+
context 'should raise error with continuation frame without more frame earlier' do
|
144
144
|
let(:encoded_text) { "\x80\x05Hello" }
|
145
145
|
let(:decoded_text) { nil }
|
146
146
|
let(:error) { WebSocket::Error::Frame::UnexpectedContinuationFrame }
|