Packages
ankh
0.4.6
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/push_promise/payload.ex
defmodule Ankh.Frame.PushPromise.Payload do
@moduledoc false
@type t :: %__MODULE__{pad_length: integer, promised_stream_id: integer, hbf: binary}
defstruct pad_length: 0, promised_stream_id: 0, hbf: <<>>
end
defimpl Ankh.Frame.Encodable, for: Ankh.Frame.PushPromise.Payload do
def encode!(
%{pad_length: pad_length, promised_stream_id: psi, hbf: hbf},
flags: %{padded: true}
) do
[<<pad_length::8, 0::1, psi::31>>, hbf, :binary.copy(<<0>>, pad_length)]
end
def encode!(%{promised_stream_id: psi, hbf: hbf}, flags: %{padded: false}) do
[<<0::1, psi::31>>, hbf]
end
def decode!(payload, <<pl::8, _::1, psi::31, data::binary>>, flags: %{padded: true}) do
hbf = binary_part(data, 0, byte_size(data) - pl)
%{payload | pad_length: pl, promised_stream_id: psi, hbf: hbf}
end
def decode!(payload, <<_::8, _::1, psi::31, hbf::binary>>, flags: %{padded: false}) do
%{payload | promised_stream_id: psi, hbf: hbf}
end
end