PcapFileEx.HTTP (pcap_file_ex v0.5.5)

View Source

Minimal HTTP decoder for payloads extracted from TCP segments.

Designed to work with payloads returned by :pkt.decode/2. It parses the request/response line, headers, and any body bytes present within the same packet.

Summary

Functions

Decodes an HTTP payload.

Same as decode/1 but raises on failure.

Types

t()

@type t() :: %PcapFileEx.HTTP{
  body: binary(),
  body_length: non_neg_integer() | nil,
  complete?: boolean(),
  decoded_body: term(),
  headers: %{optional(String.t()) => String.t()},
  method: String.t() | nil,
  raw: binary(),
  reason_phrase: String.t() | nil,
  status_code: non_neg_integer() | nil,
  type: :request | :response,
  uri: String.t() | nil,
  version: String.t()
}

Functions

decode(payload)

@spec decode(binary()) :: {:ok, t()} | {:error, atom()}

Decodes an HTTP payload.

Returns {:ok, %__MODULE__{}} on success or {:error, reason}.

decode!(payload)

@spec decode!(binary()) :: t()

Same as decode/1 but raises on failure.