futurefinity.protocol
– HTTP Protocol Implementation¶
-
class
futurefinity.protocol.
BaseHTTPConnectionController
(*args, **kwargs)[source]¶ FutureFinity Base HTTP Connection Controller Class.
This is the model controller to the HTTP Connections.
Any Connection Controllers should based on this class.
-
cancel_timeout_handler
()[source]¶ Cancel the EventLoop.call_later instance, prevent transport be closed accidently.
-
error_received
(incoming, exc: tuple)[source]¶ Triggered when errors received when errors occurred during parsing the message.
-
initial_received
(incoming: futurefinity.protocol.HTTPIncomingMessage)[source]¶ Triggered when the initial of a message is received.
-
message_received
(incoming: futurefinity.protocol.HTTPIncomingMessage)[source]¶ Triggered when a message is completely received.
This will not be triggered when the message is detected as a stream message.
-
-
class
futurefinity.protocol.
CapitalizedHTTPv1Headers
(*args, **kwargs)[source]¶ Convert a string to HTTPHeader style capitalize.
>>> capitalize_header = CapitalizedHTTPv1Header() >>> capitalize_header["set-cookie"] 'Set-Cookie' >>> capitalize_header["SET-COOKIE"] 'Set-Cookie' >>> capitalize_header["sET-CooKIe"] 'Set-Cookie' >>> capitalize_header["MY-cUsToM-heAdER"] 'My-Custom-Header'
-
exception
futurefinity.protocol.
ConnectionBadMessage
[source]¶ FutureFinity Connection Bad Message Error.
This Error is raised when the message is not a valid message.
-
exception
futurefinity.protocol.
ConnectionEntityTooLarge
[source]¶ FutureFinity Connection Entity Too Large Error.
This Error is raised when the message too large that FutureFinity cannot handle.
-
exception
futurefinity.protocol.
ConnectionParseError
[source]¶ FutureFinity Connection Parse Error.
Any Connection Parse Errors is based on this class.
-
class
futurefinity.protocol.
HTTPHeaders
(*args, **kwargs)[source]¶ HTTPHeaders class, based on TolerantMagicDict.
It has not only all the features from TolerantMagicDict, but also can parse and make HTTP Headers.
Insert all the cookies as a request cookie header.
Insert all the cookies as response set cookie headers.
-
class
futurefinity.protocol.
HTTPIncomingMessage
[source]¶ FutureFinity HTTP Incoming Message Class.
This is the base class of HTTPIncomingRequest and HTTPIncomingResponse.
-
scheme
¶ Return the scheme that the connection used.
-
-
class
futurefinity.protocol.
HTTPIncomingRequest
(method: str, origin_path: str, headers: futurefinity.protocol.HTTPHeaders, connection: 'HTTPv1Connection', http_version: int=10, body: typing.Union=None)[source]¶ FutureFinity HTTP Incoming Request Class.
This is a subclass of the HTTPIncomingMessage.
This class represents a Incoming HTTP Request.
-
body_args
¶ Parse body arguments and return body arguments in a proper instance.
Parse cookies and return cookies in a HTTPCookies instance.
-
host
¶ Parse host and return the host in str.
-
link_args
¶ Parse link arguments and return link arguments in a TolerantMagicDict instance.
-
path
¶ Parse path and return the path in str.
-
-
class
futurefinity.protocol.
HTTPIncomingResponse
(status_code: int, http_version: int=10, headers: futurefinity.protocol.HTTPHeaders=None, body: typing.Union=None, connection: 'HTTPv1Connection'=None)[source]¶ FutureFinity HTTP Incoming Response Class.
This is a subclass of the HTTPIncomingMessage.
This class represents a Incoming HTTP Response.
Parse cookies and return cookies in a HTTPCookies instance.
-
class
futurefinity.protocol.
HTTPMultipartBody
(*args, **kwargs)[source]¶ HTTPBody class, based on TolerantMagicDict.
It has not only all the features from TolerantMagicDict, but also can parse and make HTTP Body.
-
class
futurefinity.protocol.
HTTPMultipartFileField
(fieldname: str, filename: str, content: bytes, content_type: str='application/octet-stream', headers: typing.Union=None, encoding: str='binary')[source]¶ Containing a file as a http form field.
-
class
futurefinity.protocol.
HTTPv1Connection
(controller: futurefinity.protocol.BaseHTTPConnectionController, is_client: bool, http_version: int=10, use_tls: bool=False, sockname: typing.Union=None, peername: typing.Union=None, allow_keep_alive: bool=True)[source]¶ FutureFinity HTTP v1 Connection Class.
This class will control and parse the http v1 connection.
-
finish_writing
()[source]¶ Trigger this function when everything is written.
It will reset the connection or close it.
-