Skip to content

Commit 76e7bc0

Browse files
committed
Ensure ping reply payload is packed correctly.
1 parent fb6719f commit 76e7bc0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/protocol/websocket/ping_frame.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PingFrame < Frame
1515
# Generate a suitable reply.
1616
# @returns [PongFrame]
1717
def reply(**options)
18-
PongFrame.new(true, self.unpack, **options)
18+
PongFrame.new(true, **options).pack(self.unpack)
1919
end
2020

2121
# Apply this frame to the specified connection.

test/protocol/websocket/ping_frame.rb

+12
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,16 @@
1515
it "is a control frame" do
1616
expect(frame).to be(:control?)
1717
end
18+
19+
with "#reply" do
20+
it "can generate an appropriately masked reply" do
21+
frame.pack("Hello, World!")
22+
23+
reply = frame.reply(mask: "mask")
24+
25+
expect(reply.mask).to be == "mask"
26+
expect(reply.payload).not.to be == "Hello, World!"
27+
expect(reply.unpack).to be == "Hello, World!"
28+
end
29+
end
1830
end

0 commit comments

Comments
 (0)