class documentation

class HttpRequest(object):

Constructor: HttpRequest(http, postproc, uri, method, ...)

View In Hierarchy

Encapsulates a single HTTP request.

Static Method from_json Returns an HttpRequest populated with info from a JSON object.
Static Method null_postproc Undocumented
Method __init__ Constructor for an HttpRequest.
Method add_response_callback add_response_headers_callback
Method execute Execute the request.
Method next_chunk Execute the next step of a resumable upload.
Method to_json Returns a JSON representation of the HttpRequest.
Instance Variable body Undocumented
Instance Variable body_size Undocumented
Instance Variable headers Undocumented
Instance Variable http Undocumented
Instance Variable method Undocumented
Instance Variable methodId Undocumented
Instance Variable postproc Undocumented
Instance Variable response_callbacks Undocumented
Instance Variable resumable Undocumented
Instance Variable resumable_progress Undocumented
Instance Variable resumable_uri Undocumented
Instance Variable uri Undocumented
Method _process_response Process the response from a single chunk upload.
Instance Variable _in_error_state Undocumented
Instance Variable _rand Undocumented
Instance Variable _sleep Undocumented
@staticmethod
def from_json(s, http, postproc):

Returns an HttpRequest populated with info from a JSON object.

@staticmethod
def null_postproc(resp, contents):

Undocumented

@util.positional(4)
def __init__(self, http, postproc, uri, method='GET', body=None, headers=None, methodId=None, resumable=None):

Constructor for an HttpRequest.

Parameters
httphttplib2.Http, the transport object to use to make a request
postproccallable, called on the HTTP response and content to transform it into a data object before returning, or raising an exception on an error.
uristring, the absolute URI to send the request to
methodstring, the HTTP method to use
bodystring, the request body of the HTTP request,
headersdict, the HTTP request headers
methodIdstring, a unique identifier for the API method being called.
resumableMediaUpload, None if this is not a resumbale request.
@util.positional(2)
def add_response_callback(self, cb):

add_response_headers_callback

Parameters
cbCallback to be called on receiving the response headers, of signature:
def cb:resp# Where resp is an instance of httplib2.Response
@util.positional(1)
def execute(self, http=None, num_retries=0):

Execute the request.

Parameters
httphttplib2.Http, an http object to be used in place of the one the HttpRequest request object was constructed with.
num_retriesInteger, number of times to retry with randomized exponential backoff. If all retries fail, the raised HttpError represents the last request. If zero (default), we attempt the request only once.
Returns
A deserialized object model of the response body as determined by the postproc.
Raises
googleapiclient.errors.HttpError if the response was not a 2xx.
httplib2.HttpLib2Error if a transport error has occurred.
@util.positional(1)
def next_chunk(self, http=None, num_retries=0):

Execute the next step of a resumable upload.

Can only be used if the method being executed supports media uploads and the MediaUpload object passed in was flagged as using resumable upload.

Example

media = MediaFileUpload('cow.png', mimetype='image/png',
chunksize=1000, resumable=True)
request = farm.animals().insert(
id='cow', name='cow.png', media_body=media)

response = None while response is None:

status, response = request.next_chunk() if status:

print "Upload %d%% complete." % int(status.progress() * 100)
Parameters
httphttplib2.Http, an http object to be used in place of the one the HttpRequest request object was constructed with.
num_retriesInteger, number of times to retry with randomized exponential backoff. If all retries fail, the raised HttpError represents the last request. If zero (default), we attempt the request only once.
Returns
(status, body)
(ResumableMediaStatus, object)
The body will be None until the resumable media is fully uploaded.
Raises
googleapiclient.errors.HttpError if the response was not a 2xx.
httplib2.HttpLib2Error if a transport error has occurred.
def to_json(self):

Returns a JSON representation of the HttpRequest.

body =

Undocumented

body_size =

Undocumented

headers =

Undocumented

http =

Undocumented

method: str =

Undocumented

methodId =

Undocumented

postproc =

Undocumented

response_callbacks: list =

Undocumented

resumable =

Undocumented

resumable_progress: int =

Undocumented

resumable_uri =

Undocumented

uri =

Undocumented

def _process_response(self, resp, content):

Process the response from a single chunk upload.

Parameters
resphttplib2.Response, the response object.
contentstring, the content of the response.
Returns
(status, body)
(ResumableMediaStatus, object)
The body will be None until the resumable media is fully uploaded.
Raises
googleapiclient.errors.HttpError if the response was not a 2xx or a 308.
_in_error_state: bool =

Undocumented

_rand =

Undocumented

_sleep =

Undocumented