The http Module

The http module wraps the underlying raw HTTP request module (httplib2 currently) to separate the job of exposing the API from the job of dealing with lower-level interfacing with the HTTP client in use today.

class pyrabbit.http.HTTPClient(server, uname, passwd, timeout=5)[source]

A wrapper for (currently) httplib2. Abstracts away things like path building, return value parsing, etc., so the api module code stays clean and easy to read/use.

decode_json_content(content)[source]

Returns the JSON-decoded Python representation of ‘content’.

Parameters:content (json) – A Python JSON object.
do_call(path, reqtype, body=None, headers=None)[source]

Send an HTTP request to the REST API.

Parameters:
  • path (string) – A URL
  • reqtype (string) – The HTTP method (GET, POST, etc.) to use in the request.
  • body (string) – A string representing any data to be sent in the body of the HTTP request.
  • headers (dictionary) – “{header-name: header-value}” dictionary.
exception pyrabbit.http.HTTPError(content, status=None, reason=None, path=None, body=None)[source]

An error response from the API server. This should be an HTTP error of some kind (404, 500, etc).

exception pyrabbit.http.NetworkError[source]

Denotes a failure to communicate with the REST API

Previous topic

The api Module

This Page