HTTP/2 - Hypertext Transfer Protocol¶
pcapkit.protocols.application.httpv2
contains
HTTP
only, which implements extractor for Hypertext Transfer
Protocol (HTTP/2) *, whose structure is described as
below:
Octets |
Bits |
Name |
Description |
---|---|---|---|
0 |
0 |
|
Length |
3 |
24 |
|
Type |
4 |
32 |
|
Flags |
5 |
40 |
Reserved |
|
5 |
41 |
|
Stream Identifier |
9 |
72 |
|
Frame Payload |
- class pcapkit.protocols.application.httpv2.HTTP(file=None, length=None, **kwargs)[source]¶
-
This class implements Hypertext Transfer Protocol (HTTP/2).
This class currently supports parsing of the following HTTP/2 frames, which are directly mapped to the
pcapkit.const.http.frame.Frame
enumeration:Frame Code
Frame Parser
- Parameters
*args (Any) – Arbitrary positional arguments.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
Protocol[PT]
- read(length=None, **kwargs)[source]¶
Read Hypertext Transfer Protocol (HTTP/2).
Structure of HTTP/2 packet [RFC 7540]:
+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +=+=============================================================+ | Frame Payload (0...) ... +---------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- classmethod id()[source]¶
Index ID of the protocol.
- Returns
Index ID of the protocol.
- Return type
tuple[Literal[“HTTP”]]
- classmethod register_frame(code, meth)[source]¶
Register a frame parser.
- Parameters
code (RegType_Frame) – HTTP frame type code.
meth (str | FrameParser) – Method name or callable to parse the frame.
- Return type
None
- _read_http_none(frame, length, flags, sid)[source]¶
Read HTTP packet with unassigned type.
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_data(frame, length, flags, sid)[source]¶
Read HTTP/2
DATA
frames.Structure of HTTP/2
DATA
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------+-----------------------------------------------+ |Pad Length? (8)| +---------------+-----------------------------------------------+ | Data (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+
- _read_http_headers(frame, length, flags, sid)[source]¶
Read HTTP/2
HEADERS
frames.Structure of HTTP/2
HEADERS
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------+-----------------------------------------------+ |Pad Length? (8)| +-+-------------+-----------------------------------------------+ |E| Stream Dependency? (31) | +-+-------------+-----------------------------------------------+ | Weight? (8) | +-+-------------+-----------------------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_priority(frame, length, flags, sid)[source]¶
Read HTTP/2
PRIORITY
frames.Structure of HTTP/2
PRIORITY
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +-+-------------------------------------------------------------+ |E| Stream Dependency (31) | +-+-------------+-----------------------------------------------+ | Weight (8) | +-+-------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_rst_stream(frame, length, flags, sid)[source]¶
Read HTTP/2
RST_STREAM
frames.Structure of HTTP/2
RST_STREAM
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | Error Code (32) | +---------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_settings(frame, length, flags, sid)[source]¶
Read HTTP/2
SETTINGS
frames.Structure of HTTP/2
SETTINGS
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | Identifier (16) | +-------------------------------+-------------------------------+ | Value (32) | +---------------------------------------------------------------+ | ...... |
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_push_promise(frame, length, flags, sid)[source]¶
Read HTTP/2
PUSH_PROMISE
frames.Structure of HTTP/2
PUSH_PROMISE
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------+-----------------------------------------------+ |Pad Length? (8)| +-+-------------+-----------------------------------------------+ |R| Promised Stream ID (31) | +-+-----------------------------+-------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_ping(frame, length, flags, sid)[source]¶
Read HTTP/2
PING
frames.Structure of HTTP/2
PING
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | | | Opaque Data (64) | | | +---------------------------------------------------------------+
- _read_http_goaway(frame, length, flags, sid)[source]¶
Read HTTP/2
GOAWAY
frames.Structure of HTTP/2
GOAWAY
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +-+-------------+---------------+-------------------------------+ |R| Last-Stream-ID (31) | +-+-------------------------------------------------------------+ | Error Code (32) | +---------------------------------------------------------------+ | Additional Debug Data (*) | +---------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_window_update(frame, length, flags, sid)[source]¶
Read HTTP/2
WINDOW_UPDATE
frames.Structure of HTTP/2
WINDOW_UPDATE
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +-+-------------+---------------+-------------------------------+ |R| Window Size Increment (31) | +-+-------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- _read_http_continuation(frame, length, flags, sid)[source]¶
Read HTTP/2
CONTINUATION
frames.Structure of HTTP/2
CONTINUATION
frame [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+
- Parameters
- Return type
- Returns
Parsed packet data.
- Raises
ProtocolError – If the packet is malformed.
- __frame__: DefaultDict[int, str | FrameParser]¶
Frame code to method mapping, c.f.
read()
. Method names are expected to be referred to the class by_read_http_${name}
, and if such name not found, the value should then be a method that can parse the frame by itself.- Type
DefaultDict[RegType_Frame, str | FrameParser]
Data Structures¶
- class pcapkit.protocols.data.application.httpv2.HTTP(length, type, flags, sid)[source]¶
Bases:
HTTP
Data model for HTTP/2 protocol.
- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.Flags[source]¶
Bases:
Info
Data model for HTTP/2 flags.
- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.UnassignedFrame(length, type, flags, sid, data)[source]¶
Bases:
HTTP
Data model for HTTP/2 unassigned frame.
- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.DataFrame(length, type, flags, sid, pad_len, data)[source]¶
Bases:
HTTP
Data model for HTTP/2
DATA
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: DataFrameFlags¶
Flags.
- class pcapkit.protocols.data.application.httpv2.DataFrameFlags(END_STREAM, PADDED)[source]¶
Bases:
Flags
Data model for HTTP/2
DATA
frame flags.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.HeadersFrame(length, type, flags, sid, pad_len, excl_dependency, stream_dependency, weight, fragment)[source]¶
Bases:
HTTP
Data model for HTTP/2
HEADERS
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: HeadersFrameFlags¶
Flags.
- class pcapkit.protocols.data.application.httpv2.HeadersFrameFlags(END_STREAM, END_HEADERS, PADDED, PRIORITY)[source]¶
Bases:
Flags
Data model for HTTP/2
HEADERS
frame flags.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.PriorityFrame(length, type, flags, sid, excl_dependency, stream_dependency, weight)[source]¶
Bases:
HTTP
Data model for HTTP/2
PRIORITY
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: Literal[None]¶
Flags.
- class pcapkit.protocols.data.application.httpv2.RstStreamFrame(length, type, flags, sid, error)[source]¶
Bases:
HTTP
Data model for HTTP/2
RST_STREAM
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: Literal[None]¶
Flags.
- class pcapkit.protocols.data.application.httpv2.SettingsFrame(length, type, flags, sid, settings)[source]¶
Bases:
HTTP
Data model for HTTP/2
SETTINGS
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: SettingsFrameFlags¶
Flags.
- settings: OrderedMultiDict[Setting, int]¶
Settings.
- class pcapkit.protocols.data.application.httpv2.SettingsFrameFlags(ACK)[source]¶
Bases:
Flags
Data model for HTTP/2
SETTINGS
frame flags.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.PushPromiseFrame(length, type, flags, sid, pad_len, promised_sid, fragment)[source]¶
Bases:
HTTP
Data model for HTTP/2
PUSH_PROMISE
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: PushPromiseFrameFlags¶
Flags.
- class pcapkit.protocols.data.application.httpv2.PushPromiseFrameFlags(END_HEADERS, PADDED)[source]¶
Bases:
Flags
Data model for HTTP/2
PUSH_PROMISE
frame flags.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.PingFrame(length, type, flags, sid, data)[source]¶
Bases:
HTTP
Data model for HTTP/2
PING
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: PingFrameFlags¶
Flags.
- class pcapkit.protocols.data.application.httpv2.PingFrameFlags(ACK)[source]¶
Bases:
Flags
Data model for HTTP/2
PING
frame flags.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- class pcapkit.protocols.data.application.httpv2.GoawayFrame(length, type, flags, sid, last_sid, error, debug_data)[source]¶
Bases:
HTTP
Data model for HTTP/2
GOAWAY
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: Literal[None]¶
Flags.
- class pcapkit.protocols.data.application.httpv2.WindowUpdateFrame(length, type, flags, sid, increment)[source]¶
Bases:
HTTP
Data moddel for HTTP/2
WINDOW_UPDATE
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: Literal[None]¶
Flags.
- class pcapkit.protocols.data.application.httpv2.ContinuationFrame(length, type, flags, sid, fragment)[source]¶
Bases:
HTTP
Data model for HTTP/2
CONTINUATION
frame.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type
- flags: ContinuationFrameFlags¶
Flags.
- class pcapkit.protocols.data.application.httpv2.ContinuationFrameFlags(END_HEADERS)[source]¶
Bases:
Flags
Data model for HTTP/2
CONTINUATION
frame flags.- Parameters
*args (VT) – Arbitrary positional arguments.
**kwargs (VT) – Arbitrary keyword arguments.
- Return type