Source code for pcapkit.protocols.application.http
# -*- coding: utf-8 -*-"""HTTP - Hypertext Transfer Protocol========================================.. module:: pcapkit.protocols.application.http:mod:`pcapkit.protocols.application.http` contains:class:`~pcapkit.protocols.application.http.HTTP`only, which is a base class for Hypertext TransferProtocol (HTTP) [*]_ family, eg.:class:`HTTP/1.* <pcapkit.protocols.application.application.httpv1>`and :class:`HTTP/2 <pcapkit.protocols.application.application.httpv2>`... [*] https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol"""importcontextlibfromtypingimportTYPE_CHECKING,Genericfrompcapkit.protocols.application.applicationimportApplicationfrompcapkit.protocols.protocolimport_PT,_STfrompcapkit.utilities.exceptionsimportProtocolErrorifTYPE_CHECKING:fromtypingimportAny,Optionalfromtyping_extensionsimportLiteral__all__=['HTTP']
[docs]classHTTP(Application[_PT,_ST],Generic[_PT,_ST]):"""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`] """ifTYPE_CHECKING:#: Saved subclass protocol data (only for HTTP base class)._http:'HTTP[_PT, _ST]'########################################################################### Properties.##########################################################################@propertydefname(self)->'Literal["Hypertext Transfer Protocol"]':"""Name of current protocol."""return'Hypertext Transfer Protocol'@propertydefalias(self)->'Literal["HTTP/0.9", "HTTP/1.0", "HTTP/1.1", "HTTP/2"]':"""Acronym of current protocol."""returnf'HTTP/{self.version}'# type: ignore[return-value]@propertydeflength(self)->'int':"""Header length of current protocol."""returnself._length@propertydefversion(self)->'Literal["0.9", "1.0", "1.1", "2"]':"""Version of current protocol."""returnself._version########################################################################### Methods.##########################################################################
[docs]@classmethoddefid(cls)->'tuple[Literal["HTTP"], Literal["HTTPv1"], Literal["HTTPv2"]]':"""Index ID of the protocol."""return('HTTP','HTTPv1','HTTPv2')