1.1.1 Http Objects

Http objects have the following methods:

request( uri, [method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None])
Performs a single HTTP request. The uri is the URI of the HTTP resource and can begin with either http or https. The value of uri must be an absolute URI.

The method is the HTTP method to perform, such as GET, POST, DELETE, etc. There is no restriction on the methods allowed.

The body is the entity body to be sent with the request. It is a string object.

Any extra headers that are to be sent with the request should be provided in the headers dictionary.

The maximum number of redirect to follow before raising an exception is redirections. The default is 5.

The connection_type is the type of connection object to use. The supplied class should implement the interface of httplib.HTTPConnection.

The return value is a tuple of (response, content), the first being and instance of the Response class, the second being a string that contains the response entity body.

add_credentials( name, password, [domain=None])
Adds a name and password that will be used when a request requires authentication. Supplying the optional domain name will restrict these credentials to only be sent to the specified domain. If domain is not specified then the given credentials will be used to try to satisfy every HTTP 401 challenge.

add_certificate( key, cert, domain)
Add a key and cert that will be used for an SSL connection to the specified domain. keyfile is the name of a PEM formatted file that contains your private key. certfile is a PEM formatted certificate chain file.

clear_credentials( )
Remove all the names and passwords used for authentication.

follow_redirects
If True, which is the default, safe redirects are followed, where safe means that the client is only doing a GET or HEAD on the URI to which it is being redirected. If False then no redirects are followed. Note that a False 'follow_redirects' takes precedence over a True 'follow_all_redirects'. Another way of saying that is for 'follow_all_redirects' to have any affect, 'follow_redirects' must be True.

follow_all_redirects
If False, which is the default, only safe redirects are followed, where safe means that the client is only doing a GET or HEAD on the URI to which it is being redirected. If True then all redirects are followed. Note that a False 'follow_redirects' takes precedence over a True 'follow_all_redirects'. Another way of saying that is for 'follow_all_redirects' to have any affect, 'follow_redirects' must be True.

force_exception_to_status_code
If True, which is the default, then no httplib2 exceptions will be thrown. Instead, those error conditions will be turned into Response objects that will be returned normally.

If False, then exceptions will be thrown.

ignore_etag
Defaults to False. If True, then any etags present in the cached response are ignored when processing the current request, i.e. httplib2 does not use 'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This is mainly to deal with broken servers which supply an etag, but change it capriciously.