HTTP/1.* - Hypertext Transfer Protocol¶
pcapkit.protocols.application.httpv1
contains
HTTP
only, which implements extractor for Hypertext Transfer
Protocol (HTTP/1.*) [*], whose structure is described
as below:
METHOD URL HTTP/VERSION\r\n :==: REQUEST LINE
<key> : <value>\r\n :==: REQUEST HEADER
............ (Ellipsis) :==: REQUEST HEADER
\r\n :==: REQUEST SEPARATOR
<body> :==: REQUEST BODY (optional)
HTTP/VERSION CODE DESP \r\n :==: RESPONSE LINE
<key> : <value>\r\n :==: RESPONSE HEADER
............ (Ellipsis) :==: RESPONSE HEADER
\r\n :==: RESPONSE SEPARATOR
<body> :==: RESPONSE BODY (optional)
- class pcapkit.protocols.application.httpv1.HTTP(file=None, length=None, **kwargs)[source]¶
-
This class implements Hypertext Transfer Protocol (HTTP/1.*).
- property alias: Literal['HTTP/0.9', 'HTTP/1.0', 'HTTP/1.1']¶
Acronym of current protocol.
- read(length=None, **kwargs)[source]¶
Read Hypertext Transfer Protocol (HTTP/1.*).
Structure of HTTP/1.* packet [RFC 7230]:
HTTP-message :==: start-line *( header-field CRLF ) CRLF [ message-body ]
- Parameters:
- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the packet is malformed.
- make(http_version='1.1', method=None, uri=None, status=None, status_default=None, status_namespace=None, status_reversed=False, message=None, headers=None, body=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
http_version (
Literal
['0.9'
,'1.0'
,'1.1'
,b'0.9'
,b'1.0'
,b'1.1'
]) – HTTP version.status (
Union
[StatusCode
,str
,bytes
,int
,None
]) – HTTP status code.status_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace of HTTP status code.status_reversed (
bool
) – Whether to reverse the namespace.headers (
Optional
[OrderedMultiDict
[str
,str
]]) – HTTP headers.body (
bytes
) – HTTP body.**kwargs (
Any
) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- _read_http_header(header)[source]¶
Read HTTP/1.* header.
Structure of HTTP/1.* header [RFC 7230]:
start-line :==: request-line / status-line request-line :==: method SP request-target SP HTTP-version CRLF status-line :==: HTTP-version SP status-code SP reason-phrase CRLF header-field :==: field-name ":" OWS field-value OWS
- Parameters:
header (
bytes
) – HTTP header data.- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the packet is malformed.
Auxiliary Data¶
- class pcapkit.protocols.application.httpv1.Type(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
StrEnum
HTTP packet type.
- REQUEST = 'request'¶
Request packet.
- RESPONSE = 'response'¶
Response packet.
- static _generate_next_value_(name, start, count, last_values)¶
Return the lower-cased version of the member name.
Header Schemas¶
Data Models¶
- class pcapkit.protocols.data.application.httpv1.HTTP(*args: VT, **kwargs: VT)[source]¶
Bases:
Protocol
Data model for HTTP/1.* protocol.
- receipt: Header¶
HTTP receipt.
- header: OrderedMultiDict[str, str]¶
HTTP header.
- body: Any¶
HTTP body.
- class pcapkit.protocols.data.application.httpv1.Header(dict_=None, **kwargs)[source]¶
Bases:
Data
Data model for HTTP/1.* header line.
- type: HTTP_Type¶
Receipt type.
- class pcapkit.protocols.data.application.httpv1.RequestHeader(*args: VT, **kwargs: VT)[source]¶
Bases:
Header
Data model for HTTP/1.* request header line.
- type: HTTP_Type¶
HTTP request header line.
- method: Enum_Method¶
HTTP method.
- uri: str¶
HTTP request URI.
- version: str¶
HTTP request version.
- class pcapkit.protocols.data.application.httpv1.ResponseHeader(*args: VT, **kwargs: VT)[source]¶
Bases:
Header
Data model for HTTP/1.* response header line.
- type: HTTP_Type¶
HTTP response header line.
- version: str¶
HTTP response version.
- status: Enum_StatusCode¶
HTTP response status.
- message: str¶
HTTP response status message.
Footnotes