Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Factor out 'storage.connection.Connection._do_request()'.
In preparation for making 'storage.batch.Batch' derive from Connection,
allowing it to override only the actual transmission of the HTTP request.
  • Loading branch information
tseaver committed Feb 25, 2015
commit 63ea7ba6e758577f050191df693a470bfda96d3f
27 changes: 26 additions & 1 deletion gcloud/storage/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def _make_request(self, method, url, data=None, content_type=None,

:rtype: tuple of ``response`` (a dictionary of sorts)
and ``content`` (a string).
:returns: The HTTP response object and the content of the response.
:returns: The HTTP response object and the content of the response,
returned by :meth:`_do_request`.
"""
headers = headers or {}
headers['Accept-Encoding'] = 'gzip'
Expand All @@ -166,6 +167,30 @@ def _make_request(self, method, url, data=None, content_type=None,

headers['User-Agent'] = self.USER_AGENT

return self._do_request(method, url, headers, data)

def _do_request(self, method, url, headers, data):
"""Low-level helper: perform the actual API request over HTTP.

Allows :class:`gcloud.storage.batch.Batch` to override, deferring
the request.

:type method: string
:param method: The HTTP method to use in the request.

:type url: string
:param url: The URL to send the request to.

:type headers: dict
:param headers: A dictionary of HTTP headers to send with the request.

:type data: string
:param data: The data to send as the body of the request.

:rtype: tuple of ``response`` (a dictionary of sorts)
and ``content`` (a string).
:returns: The HTTP response object and the content of the response.
"""
return self.http.request(uri=url, method=method, headers=headers,
body=data)

Expand Down