Classes to encapsulate a single HTTP request.
The classes implement a command pattern, with every object supporting an execute() method that does the actual HTTP request.
| Class | |
Batches multiple HttpRequest objects into a single HTTP request. |
| Class | |
Mock of httplib2.Http |
| Class | |
Mock of httplib2.Http |
| Class | |
Encapsulates a single HTTP request. |
| Class | |
Mock of HttpRequest. |
| Class | |
Status of a resumable download. |
| Class | |
A MediaUpload for a file. |
| Class | |
MediaUpload for a chunk of bytes. |
| Class | |
"Download media resources. |
| Class | |
A MediaUpload for a io.Base objects. |
| Class | |
Describes a media object to upload. |
| Class | |
Status of a resumable upload. |
| Class | |
A simple mock of HttpRequest |
| Function | build |
Builds httplib2.Http object |
| Function | set |
Set the user-agent on every request. |
| Function | tunnel |
Tunnel PATCH requests over POST. |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | LOGGER |
Undocumented |
| Constant | MAX |
Undocumented |
| Constant | MAX |
Undocumented |
| Variable | __author__ |
Undocumented |
| Class | _ |
Truncated stream. |
| Function | _retry |
Retries an HTTP request multiple times while handling errors. |
| Function | _should |
Determines whether a response should be retried. |
| Constant | _LEGACY |
Undocumented |
| Constant | _TOO |
Undocumented |
Builds httplib2.Http object
Returns: A httplib2.Http object, which is used to make http requests, and which has timeout set by default. To override default timeout call
socket.setdefaulttimeout(timeout_in_sec)
before interacting with this method.
Set the user-agent on every request.
Example
h = httplib2.Http() h = set_user_agent(h, "my-app-name/6.0")
Most of the time the user-agent will be set doing auth, this is for the rare cases where you are accessing an unauthenticated endpoint.
| Parameters | |
| http | Undocumented |
| user | string, the value for the user-agent header. |
| http - | or something that acts like it. |
| Returns | |
| A modified instance of http that was passed in. | |
Tunnel PATCH requests over POST.
Example
h = httplib2.Http() h = tunnel_patch(h, "my-app-name/6.0")
Useful if you are running on a platform that doesn't support PATCH. Apply this last if you are using OAuth 1.0, as changing the method will result in a different signature.
| Parameters | |
| http | Undocumented |
| http - | or something that acts like it. |
| Returns | |
| A modified instance of http that was passed in. | |
Retries an HTTP request multiple times while handling errors.
If after all retries the request still fails, last error is either returned as return value (for HTTP 5xx errors) or thrown (for ssl.SSLError).
| Parameters | |
| http | Http object to be used to execute request. |
| num | Maximum number of retries. |
| req | Type of the request (used for logging retries). |
| sleep | Functions to sleep for random time between retries. |
| rand | Functions to sleep for random time between retries. |
| uri | URI to be requested. |
| method | HTTP method to be used. |
| *args | Additional arguments passed to http.request. |
| **kwargs | Additional arguments passed to http.request. |
| Returns | |
| resp, content - Response from the http request (may be HTTP 5xx). | |