HTTP/2 - Hypertext Transfer Protocol¶
pcapkit.protocols.application.httpv2 contains
HTTPv2
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.HTTPv2(file=None, length=None, **kwargs)[source]¶ Bases:
pcapkit.protocols.application.http.HTTPThis class implements Hypertext Transfer Protocol (HTTP/2).
-
_read_http_continuation(size, kind, flag)[source]¶ Read HTTP/2
CONTINUATIONframes.Structure of HTTP/2
CONTINUATIONframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_data(size, kind, flag)[source]¶ Read HTTP/2
DATAframes.Structure of HTTP/2
DATAframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------+-----------------------------------------------+ |Pad Length? (8)| +---------------+-----------------------------------------------+ | Data (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_goaway(size, kind, flag)[source]¶ Read HTTP/2
GOAWAYframes.Structure of HTTP/2
GOAWAYframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +-+-------------+---------------+-------------------------------+ |R| Last-Stream-ID (31) | +-+-------------------------------------------------------------+ | Error Code (32) | +---------------------------------------------------------------+ | Additional Debug Data (*) | +---------------------------------------------------------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_headers(size, kind, flag)[source]¶ Read HTTP/2
HEADERSframes.Structure of HTTP/2
HEADERSframe [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
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_none(size, kind, flag)[source]¶ Read HTTP packet with unassigned type.
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_ping(size, kind, flag)[source]¶ Read HTTP/2
PINGframes.Structure of HTTP/2
PINGframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | | | Opaque Data (64) | | | +---------------------------------------------------------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_priority(size, kind, flag)[source]¶ Read HTTP/2
PRIORITYframes.Structure of HTTP/2
PRIORITYframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +-+-------------------------------------------------------------+ |E| Stream Dependency (31) | +-+-------------+-----------------------------------------------+ | Weight (8) | +-+-------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_push_promise(size, kind, flag)[source]¶ Read HTTP/2
PUSH_PROMISEframes.Structure of HTTP/2
PUSH_PROMISEframe [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
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_rst_stream(size, kind, flag)[source]¶ Read HTTP/2
RST_STREAMframes.Structure of HTTP/2
RST_STREAMframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | Error Code (32) | +---------------------------------------------------------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_settings(size, kind, flag)[source]¶ Read HTTP/2
SETTINGSframes.Structure of HTTP/2
SETTINGSframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +---------------------------------------------------------------+ | Identifier (16) | +-------------------------------+-------------------------------+ | Value (32) | +---------------------------------------------------------------+ | ...... |
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
_read_http_window_update(size, kind, flag)[source]¶ Read HTTP/2
WINDOW_UPDATEframes.Structure of HTTP/2
WINDOW_UPDATEframe [RFC 7540]:+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +-+-------------+---------------+-------------------------------+ |R| Window Size Increment (31) | +-+-------------------------------------------------------------+
- Parameters
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
classmethod
id()[source]¶ Index ID of the protocol.
- Returns
Index ID of the protocol.
- Return type
Literal[‘HTTPv2’]
-
make(**kwargs)[source]¶ Make (construct) packet data.
- Keyword Arguments
**kwargs – Arbitrary keyword arguments.
- Returns
Constructed packet data.
- Return type
-
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
length (Optional[int]) – Length of packet data.
- Keyword Arguments
**kwargs – Arbitrary keyword arguments.
- Returns
Parsed packet data.
- Return type
- Raises
ProtocolError – If the packet is malformed.
-
property
alias¶ Acronym of current protocol.
- Return type
Literal[‘HTTP/2’]
-
-
pcapkit.protocols.application.httpv2._HTTP_FUNC: Dict[int, Callable[[pcapkit.protocols.application.httpv2.HTTPv2, int, int, str], DataType_HTTPv2_Frame]]¶ Process method for HTTP/2 packets.
Code
Method
Description
N/A
Unsigned
0x00
DATA0x01
HEADERS0x02
PRIORITY0x03
RST_STREAM0x04
SETTINGS0x05
PUSH_PROMISE0x06
PING0x07
GOAWAY0x08
WINDOW_UPDATE0x09
CONTINUATION
Data Structure¶
Important
Following classes are only for documentation purpose.
They do NOT exist in the pcapkit module.
-
class
pcapkit.protocols.application.httpv2.DataType_HTTPv2¶ - Bases
TypedDict
Structure of HTTP/2 packet [RFC 7540].
-
type: pcapkit.const.http.frame.Frame¶ Type.
-
class
pcapkit.protocols.application.httpv2.DataType_HTTPv2_Frame¶ - Bases
TypedDict
HTTP/2 packet data.
HTTP/2 Unassigned Frame¶
HTTP/2 DATA Frame¶
For HTTP/2 DATA frame as described in RFC 7540,
its 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 |
|
Pad Length (Optional) |
10 |
80 |
|
Data |
? |
? |
Padding (Optional) |
HTTP/2 HEADERS Frame¶
For HTTP/2 HEADERS frame as described in RFC 7540,
its 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 |
|
Pad Length (Optional) |
10 |
80 |
|
Exclusive Flag |
10 |
81 |
|
Stream Dependency (Optional) |
14 |
112 |
|
Weight (Optional) |
15 |
120 |
|
Header Block Fragment |
? |
? |
Padding (Optional) |
HTTP/2 PRIORITY Frame¶
For HTTP/2 PRIORITY frame as described in RFC 7540,
its 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 |
|
Exclusive Flag |
9 |
73 |
|
Stream Dependency |
13 |
104 |
|
Weight |
HTTP/2 RST_STREAM Frame¶
For HTTP/2 RST_STREAM frame as described in RFC 7540,
its 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 |
|
Error Code |
-
class
pcapkit.protocols.application.httpv2.DataType_HTTPv2_RST_STREAM¶ - Bases
DataType_HTTPv2_Frame
Structure of HTTP/2
PRIORITYframe [RFC 7540].-
flags: Literal[None]¶ HTTP/2 packet flags.
-
error: pcapkit.const.http.error_code.ErrorCode¶ Error code.
HTTP/2 SETTINGS Frame¶
For HTTP/2 SETTINGS frame as described in RFC 7540,
its 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 |
|
Settings |
9 |
72 |
|
Identifier |
10 |
80 |
|
Value |
-
class
pcapkit.protocols.application.httpv2.DataType_HTTPv2_SETTINGS¶ - Bases
DataType_HTTPv2_Frame
Structure of HTTP/2
SETTINGSframe [RFC 7540].-
flags: DataType_HTTPv2_SETTINGS_Flags¶ HTTP/2 packet flags.
-
settings: Tuple[pcapkit.const.http.setting.Setting]¶ Array of HTTP/2 settings.
HTTP/2 PUSH_PROMISE Frame¶
For HTTP/2 PUSH_PROMISE frame as described in RFC 7540,
its 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 |
|
Pad Length (Optional) |
10 |
80 |
Reserved |
|
10 |
81 |
|
Promised Stream ID |
14 |
112 |
|
Header Block Fragment |
? |
? |
Padding (Optional) |
HTTP/2 PING Frame¶
For HTTP/2 PING frame as described in RFC 7540,
its 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 |
|
Opaque Data |
HTTP/2 GOAWAY Frame¶
For HTTP/2 GOAWAY frame as described in RFC 7540,
its 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 |
Reserved |
|
9 |
73 |
|
Last Stream ID |
13 |
104 |
|
Error Code |
17 |
136 |
|
Additional Debug Data (Optional) |
HTTP/2 WINDOW_UPDATE Frame¶
For HTTP/2 WINDOW_UPDATE frame as described in RFC 7540,
its 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 |
Reserved |
|
9 |
73 |
|
Window Size Increment |
HTTP/2 CONTINUATION Frame¶
For HTTP/2 CONTINUATION frame as described in RFC 7540,
its 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 |
73 |
|
Header Block Fragment |
-
class
pcapkit.protocols.application.httpv2.DataType_HTTPv2_CONTINUATION¶ - Bases
DataType_HTTPv2_Frame
Structure of HTTP/2
CONTINUATIONframe [RFC 7540].-
flags: DataType_HTTPv2_CONTINUATION_Flags¶ HTTP/2 packet flags.
-
class
pcapkit.protocols.application.httpv2.DataType_HTTPv2_CONTINUATION_Flags¶ - Bases
TypedDict
HTTP/2 packet flags.