aiospamc.requests module¶
Contains all requests that can be made to the SPAMD service.
-
class
aiospamc.requests.
Request
(verb, version='1.5', headers=None, body=None)¶ Bases:
aiospamc.common.RequestResponseBase
SPAMC request object.
-
verb
¶ str
– Method name of the request.
-
version
¶ str
– Protocol version.
-
body
¶ str
orbytes
– String representation of the body. An instance of theaiospamc.headers.ContentLength
will be automatically added.
-
__init__
(verb, version='1.5', headers=None, body=None)¶ Request constructor.
Parameters: - verb (
str
) – Method name of the request. - version (
str
) – Version of the protocol. - body (
str
orbytes
, optional) – String representation of the body. An instance of theaiospamc.headers.ContentLength
will be automatically added. - headers (tuple of
aiospamc.headers.Header
, optional) – Collection of headers to be added. If it contains an instance ofaiospamc.headers.Compress
then the body is automatically compressed.
- verb (
-
add_header
(header)¶ Adds a header to the request. A header with the same name will be overwritten.
Parameters: header ( aiospamc.headers.Header
) – A header object to be added.
-
body
Contains the contents of the body.
The getter will return a bytes object.
The setter expects a string. If the
aiospamc.headers.Compress
header is present then the value of body will be compressed.The deleter will automatically remove the
aiospamc.headers.ContentLength
header.
-
delete_header
(header_name)¶ Deletes the header from the request.
Parameters: header_name ( str
) – String name of the header.Raises: KeyError
-
get_header
(header_name)¶ Gets the header matching the name.
Parameters: header_name ( str
) – String name of the header.Returns: A Header object or subclass of it. Return type: aiospamc.headers.Header
Raises: KeyError
-