Home | History | Annotate | Download | only in googleapiclient

Lines Matching refs:http

7 #      http://www.apache.org/licenses/LICENSE-2.0
15 """Classes to encapsulate a single HTTP request.
19 actual HTTP request.
131 def _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args,
133 """Retries an HTTP request multiple times while handling errors.
136 return value (for HTTP 5xx errors) or thrown (for ssl.SSLError).
139 http: Http object to be used to execute request.
144 method: HTTP method to be used.
145 args, kwargs: Additional arguments passed to http.request.
148 resp, content - Response from the http request (may be HTTP 5xx).
164 resp, content = http.request(uri, method, *args, **kwargs)
255 environment where individual HTTP requests may have a hardcoded time limit,
265 later, the stream will be passed into the http library which will result in
636 request: googleapiclient.http.HttpRequest, the media request to perform in
682 http = self._request.http
685 http, num_retries, 'media download', self._sleep, self._rand, self._uri,
749 """Encapsulates a single HTTP request."""
752 def __init__(self, http, postproc, uri,
761 http: httplib2.Http, the transport object to use to make a request
762 postproc: callable, called on the HTTP response and content to transform
766 method: string, the HTTP method to use
767 body: string, the request body of the HTTP request,
768 headers: dict, the HTTP request headers
777 self.http = http
797 def execute(self, http=None, num_retries=0):
801 http: httplib2.Http, an http object to be used in place of the
816 if http is None:
817 http = self.http
822 _, body = self.next_chunk(http=http, num_retries=num_retries)
833 self.headers['x-http-method-override'] = 'GET'
845 http, num_retries, 'request', self._sleep, self._rand, str(self.uri),
867 def next_chunk(self, http=None, num_retries=0):
890 http: httplib2.Http, an http object to be used in place of the
905 if http is None:
906 http = self.http
921 http, num_retries, 'resumable URI request', self._sleep, self._rand,
936 resp, content = http.request(self.resumable_uri, 'PUT',
981 resp, content = http.request(self.resumable_uri, method='PUT',
1031 del d['http']
1039 def from_json(s, http, postproc):
1045 http,
1056 """Batches multiple HttpRequest objects into a single HTTP request.
1059 from googleapiclient.http import BatchHttpRequest
1085 batch.execute(http=http)
1096 third is an googleapiclient.errors.HttpError exception object if an HTTP error
1138 def _refresh_and_apply_credentials(self, request, http):
1143 http: httplib2.Http, the global http object for the batch.
1146 # If there is no http per the request then refresh the http passed in
1151 if request.http is not None:
1152 creds = _auth.get_credentials_from_http(request.http)
1155 if creds is None and http is not None:
1156 creds = _auth.get_credentials_from_http(http)
1163 # Only apply the credentials if we are using the http object passed in,
1165 if request.http is None or not request_credentials:
1218 The request as a string in application/http format.
1225 status_line = request.method + ' ' + request_line + ' HTTP/1.1\n'
1230 if request.http is not None:
1231 credentials = _auth.get_credentials_from_http(request.http)
1315 third is an googleapiclient.errors.HttpError exception object if an HTTP error
1341 def _execute(self, http, order, requests):
1345 http: httplib2.Http, an http object to be used to make the request with.
1362 msg = MIMENonMultipart('application', 'http')
1381 resp, content = http.request(self._batch_uri, method='POST', body=body,
1406 # We encode content here to emulate normal http response.
1412 def execute(self, http=None):
1413 """Execute all the requests as a single batched HTTP request.
1416 http: httplib2.Http, an http object to be used in place of the one the
1418 then use a http object from the requests in this batch.
1431 # If http is not supplied use the first valid one given in the requests.
1432 if http is None:
1436 http = request.http
1439 if http is None:
1440 raise ValueError("Missing a valid http object.")
1444 creds = _auth.get_credentials_from_http(http)
1450 self._execute(http, self._order, self._requests)
1462 self._refresh_and_apply_credentials(request, http)
1466 self._execute(http, redo_order, redo_requests)
1516 def execute(self, http=None):
1520 mocked and not really from an HTTP request/response.
1568 def __call__(self, http, postproc, uri, method='GET', body=None,
1599 """Mock of httplib2.Http"""
1637 """Mock of httplib2.Http
1641 and content and then use as if an httplib2.Http instance.
1643 http = HttpMockSequence([
1648 resp, content = http.request("http://examples.com")
1691 def set_user_agent(http, user_agent):
1695 http - An instance of httplib2.Http
1700 A modified instance of http that was passed in.
1704 h = httplib2.Http()
1710 request_orig = http.request
1712 # The closure that will replace 'httplib2.Http.request'.
1727 http.request = new_request
1728 return http
1731 def tunnel_patch(http):
1734 http - An instance of httplib2.Http
1738 A modified instance of http that was passed in.
1742 h = httplib2.Http()
1749 request_orig = http.request
1751 # The closure that will replace 'httplib2.Http.request'.
1762 headers['x-http-method-override'] = "PATCH"
1768 http.request = new_request
1769 return http
1773 """Builds httplib2.Http object
1776 A httplib2.Http object, which is used to make http requests, and which has timeout set by default.
1787 return httplib2.Http(timeout=http_timeout)