caviar.network.http

HTTP module.

class caviar.network.http.HTTPResource(path, protocol, host, port, auth=None, headers=None)

Bases: object

An HTTP resource.

Parameters:
  • path (list) – List of path components.
  • protocol (str) – HTTP protocol, such as ‘http’ and ‘https’.
  • host (str) – Host.
  • port (str) – Port.
  • auth – Authentication specification.
  • headers (dict) – Common headers. Each entry contains a list of values.
request(method_name)
push(name)
ref(url)
class caviar.network.http.HTTPRequest(method, protocol, host, port, path, auth, headers)

Bases: object

method
path
query_param(name, value)
data_param(name, value)
file_param(name, value)
perform()
class caviar.network.http.HTTPResponse(status_code, headers, content)

Bases: object

HTTP response attributes.

Parameters:
  • status_code (int) – Response status code.
  • headers (dict) – Dictionary with lists of strings containing response headers.
  • content (dict) – Dictionary that comes from decoding the JSON response body.
status_code

Response status code.

Return type:int
Returns:Status code value.
headers

Dictionary with lists of strings containing response headers.

Return type:dict
Returns:Headers dictionary.
content

Dictionary that comes from decoding the JSON response body.

Return type:dict
Returns:Content dictionary.
class caviar.network.http.HTTPNoneAuth

Bases: object

No authentication.

translate()

Translate it to the underlying implementation authentication.

Returns:Translated authentication.
class caviar.network.http.HTTPBasicAuth(user, password)

Bases: object

Basic authentication.

Parameters:
  • user (str) – User name.
  • password (str) – User password.
translate()

Translate it to the underlying implementation authentication.

Returns:Translated authentication.