Packages
ankh
0.7.1
0.17.0
0.16.0
0.15.0
0.14.5
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.0
0.12.1
0.12.0
0.11.0
0.10.0
0.9.0
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3
0.5.2
0.5.1
0.5.0
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Pure Elixir HTTP/2 implementation
Current section
Files
Jump to
Current section
Files
lib/ankh/frame/headers/splittable.ex
defimpl Ankh.Frame.Splittable, for: Ankh.Frame.Headers do
alias Ankh.Frame.Continuation
def split(
%{flags: %{end_stream: end_stream} = flags, payload: %{hbf: hbf}} = frame,
frame_size
)
when byte_size(hbf) <= frame_size do
[%{frame | flags: %{flags | end_headers: true, end_stream: end_stream}}]
end
def split(frame, frame_size) do
do_split(frame, frame_size, [])
end
defp do_split(
%{flags: %{end_stream: end_stream} = flags, payload: %{hbf: hbf} = payload} = frame,
frame_size,
[]
) do
<<chunk::size(frame_size), rest::binary>> = hbf
frames = [%{frame | payload: %{payload | hbf: chunk}}]
do_split(
%{
frame
| flags: %{flags | end_stream: end_stream, end_headers: false},
payload: %{hbf: rest}
},
frame_size,
frames
)
end
defp do_split(
%{stream_id: id, payload: %{hbf: hbf}},
frame_size,
frames
)
when byte_size(hbf) <= frame_size do
frame = %Continuation{
stream_id: id,
flags: %Continuation.Flags{end_headers: true},
payload: %Continuation.Payload{hbf: hbf}
}
Enum.reverse([frame | frames])
end
defp do_split(
%{stream_id: id, payload: %{hbf: hbf} = payload} = frame,
frame_size,
frames
) do
<<chunk::size(frame_size), rest::binary>> = hbf
frames = [
%Continuation{
stream_id: id,
payload: %Continuation.Payload{payload | hbf: chunk}
}
| frames
]
do_split(%{frame | payload: %{hbf: rest}}, frame_size, frames)
end
end