Skip to content

Commit

Permalink
Handle unexpected continuation frames (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfolkens authored Apr 16, 2023
1 parent cfbe7e9 commit f44a35e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/mint/web_socket/frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ defmodule Mint.WebSocket.Frame do
{:close, code, reason}
end

def translate(continuation()) do
{:error, :unexpected_continuation}
end

@doc """
Emits frames for any finalized fragments and stores any unfinalized fragments
in the `:fragment` key in the websocket data structure
Expand Down
5 changes: 5 additions & 0 deletions test/mint/web_socket/frame_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ defmodule Mint.WebSocket.FrameTest do

assert ping(fin?: true) |> is_fin()
end

test "incomplete frames should return error" do
assert {:error, :unexpected_continuation} =
translate({:continuation, <<0x0::size(3)>>, nil, "hello", true})
end
end

0 comments on commit f44a35e

Please sign in to comment.