Skip to content

Commit eef5a83

Browse files
committed
Revert "Introduce option requires_masking to Framer for enforcing masking."
This reverts commit afe247a.
1 parent 85583a3 commit eef5a83

File tree

3 files changed

+1
-23
lines changed

3 files changed

+1
-23
lines changed

lib/protocol/websocket/frame.rb

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class Frame
2323
# @parameter mask [Boolean | String] An optional 4-byte string which is used to mask the payload.
2424
def initialize(finished = true, payload = nil, flags: 0, opcode: self.class::OPCODE, mask: false)
2525
if mask == true
26-
# Generate a unique mask for each frame:
2726
mask = SecureRandom.bytes(4)
2827
end
2928

lib/protocol/websocket/framer.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ module WebSocket
2929

3030
# Wraps an underlying {Async::IO::Stream} for reading and writing binary data into structured frames.
3131
class Framer
32-
def initialize(stream, frames = FRAMES, requires_masking: false)
32+
def initialize(stream, frames = FRAMES)
3333
@stream = stream
3434
@frames = frames
35-
36-
@requires_masking = requires_masking
3735
end
3836

3937
# Close the underlying stream.
@@ -56,10 +54,6 @@ def read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE)
5654
klass = @frames[opcode] || Frame
5755
frame = klass.read(finished, flags, opcode, @stream, maximum_frame_size)
5856

59-
if @requires_masking and !frame.mask
60-
raise ProtocolError, "Received unmasked frame but requires masking!"
61-
end
62-
6357
return frame
6458
end
6559

test/protocol/websocket/framer.rb

-15
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,4 @@
1616
end.to raise_exception(EOFError, message: be =~ /Could not read frame header/)
1717
end
1818
end
19-
20-
with "requires_masking: true" do
21-
let(:framer) {subject.new(stream, requires_masking: true)}
22-
23-
it "fails if it receives an unmasked frame" do
24-
frame = Protocol::WebSocket::BinaryFrame.new(true).pack("Hello, World!")
25-
frame.write(stream)
26-
27-
stream.rewind
28-
29-
expect do
30-
framer.read_frame
31-
end.to raise_exception(Protocol::WebSocket::ProtocolError, message: be =~ /Received unmasked frame but requires masking!/)
32-
end
33-
end
3419
end

0 commit comments

Comments
 (0)