HTTP - Hypertext Transfer Protocol

pcapkit.protocols.application.http contains HTTP only, which is a base class for Hypertext Transfer Protocol (HTTP) * family, eg. HTTP/1.* and HTTP/2.

class pcapkit.protocols.application.http.HTTP(file=None, length=None, **kwargs)[source]

Bases: Application[HTTP], Generic[PT]

This class implements all protocols in HTTP family.

  • Hypertext Transfer Protocol (HTTP/1.1) [RFC 7230]

  • Hypertext Transfer Protocol version 2 (HTTP/2) [RFC 7540]

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property name: Literal['Hypertext Transfer Protocol']

Name of current protocol.

Return type

Literal[‘Hypertext Transfer Protocol’]

property alias: Literal['HTTP/0.9', 'HTTP/1.0', 'HTTP/1.1', 'HTTP/2']

Acronym of current protocol.

Return type

Literal[‘HTTP/0.9’, ‘HTTP/1.0’, ‘HTTP/1.1’, ‘HTTP/2’]

property length: int

Header length of current protocol.

Return type

int

property version: Literal['0.9', '1.0', '1.1', '2']

Version of current protocol.

Return type

Literal[‘0.9’, ‘1.0’, ‘1.1’, ‘2’]

classmethod id()[source]

Index ID of the protocol.

Return type

tuple[Literal[“HTTPv1”], Literal[“HTTPv2”]]

read(length=None, *, version=None, **kwargs)[source]

Read (parse) packet data.

Parameters
  • length (Optional[int]) – Length of packet data.

  • version (Optional[Literal[1, 2]]) – Version of HTTP.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

HTTP

Returns

Parsed packet data.

make(*, version, **kwargs)[source]

Make (construct) packet data.

Parameters
  • version (Literal[1, 2]) – Version of HTTP.

  • **kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

_guess_version(length, **kwargs)[source]

Guess HTTP version.

Parameters
  • length (int) – Length of packet data.

  • kwargs (Any) –

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Return type

Protocol

Returns

Parsed packet data.

Data Structures

class pcapkit.protocols.data.application.http.HTTP[source]

Bases: Info

Data model for HTTP protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info


*

https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol