PcapFileEx.Flows.HTTP2.Flow (pcap_file_ex v0.5.5)

View Source

An HTTP/2 flow containing streams (request/response exchanges).

Groups HTTP/2 streams that share the same client-server connection. Uses "streams" terminology to match the HTTP/2 specification.

Fields

  • flow - The base Flow identity (protocol, endpoints, display fields)
  • streams - List of HTTP2.Stream structs (complete streams with flow_seq)
  • incomplete - List of IncompleteExchange structs (not in timeline)
  • stats - Aggregate statistics for this flow

Complete vs Incomplete

  • streams contains exchanges that have both request and response
  • incomplete contains exchanges that were cut off (RST_STREAM, GOAWAY, truncated)
  • Only complete streams are included in the unified timeline

Examples

# Query flows from a specific client
result.http2
|> Enum.filter(fn f -> f.flow.from == "web-client" end)
|> Enum.flat_map(& &1.streams)

# Get all POST requests
result.http2
|> Enum.flat_map(& &1.streams)
|> Enum.filter(fn s -> s.exchange.request.method == "POST" end)

# Check for incomplete streams
result.http2
|> Enum.flat_map(& &1.incomplete)
|> Enum.each(fn incomplete ->
  IO.puts("Incomplete stream #{incomplete.stream_id}: #{incomplete.reason}")
end)

Summary

Functions

Adds an incomplete exchange to the flow.

Adds a stream to the flow.

Finalizes the flow by computing stats from all streams.

Creates a new HTTP/2 flow.

Types

t()

@type t() :: %PcapFileEx.Flows.HTTP2.Flow{
  flow: PcapFileEx.Flow.t(),
  incomplete: [PcapFileEx.HTTP2.IncompleteExchange.t()],
  stats: PcapFileEx.Flows.Stats.t(),
  streams: [PcapFileEx.Flows.HTTP2.Stream.t()]
}

Functions

add_incomplete(http2_flow, incomplete)

@spec add_incomplete(t(), PcapFileEx.HTTP2.IncompleteExchange.t()) :: t()

Adds an incomplete exchange to the flow.

Parameters

  • http2_flow - The HTTP/2 flow
  • incomplete - The incomplete exchange to add

add_stream(http2_flow, stream)

@spec add_stream(t(), PcapFileEx.Flows.HTTP2.Stream.t()) :: t()

Adds a stream to the flow.

Parameters

  • http2_flow - The HTTP/2 flow
  • stream - The stream to add

finalize(http2_flow)

@spec finalize(t()) :: t()

Finalizes the flow by computing stats from all streams.

Called after all streams have been added.

new(flow)

@spec new(PcapFileEx.Flow.t()) :: t()

Creates a new HTTP/2 flow.

Parameters

  • flow - The base Flow identity

Examples

alias PcapFileEx.{Flow, Endpoint}
alias PcapFileEx.Flows.HTTP2

client = Endpoint.new("10.0.0.1", 54321)
server = Endpoint.new("10.0.0.2", 8080)
flow = Flow.new(:http2, client, server)
http2_flow = HTTP2.Flow.new(flow)