Skip to content

Commit f44a35e

Browse files
authored
Handle unexpected continuation frames (#33)
1 parent cfbe7e9 commit f44a35e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/mint/web_socket/frame.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ defmodule Mint.WebSocket.Frame do
431431
{:close, code, reason}
432432
end
433433

434+
def translate(continuation()) do
435+
{:error, :unexpected_continuation}
436+
end
437+
434438
@doc """
435439
Emits frames for any finalized fragments and stores any unfinalized fragments
436440
in the `:fragment` key in the websocket data structure

test/mint/web_socket/frame_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ defmodule Mint.WebSocket.FrameTest do
99

1010
assert ping(fin?: true) |> is_fin()
1111
end
12+
13+
test "incomplete frames should return error" do
14+
assert {:error, :unexpected_continuation} =
15+
translate({:continuation, <<0x0::size(3)>>, nil, "hello", true})
16+
end
1217
end

0 commit comments

Comments
 (0)