Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Add urllib3 transport #659

Merged

Conversation

theacodes
Copy link
Contributor

No description provided.

refresh_status_codes (Sequence): Which HTTP status code indicate that
credentials should be refreshed and the request should be retried.
"""
def __init__(self, http, credentials, refresh_status_codes):

This comment was marked as spam.

This comment was marked as spam.

self.refresh_status_codes = refresh_status_codes

def urlopen(self, method, url, body=None, headers=None,
_credential_refresh_attempt=0, **kwargs):

This comment was marked as spam.

This comment was marked as spam.

headers = self.headers

# Copy the request headers because this may be called recursively.
request_headers = _helpers.initialize_headers(headers).copy()

This comment was marked as spam.

This comment was marked as spam.

return urllib3.PoolManager(*args, **kwargs)


class AuthorizedHttp(request.RequestMethods):

This comment was marked as spam.

This comment was marked as spam.

# A stored token may expire between the time it is retrieved and
# the time the request is made, so we may need to try twice.
# The reason urllib3's retries aren't used is because they
# don't allow you to modify the request headers. :/

This comment was marked as spam.

This comment was marked as spam.


The behavior is transport-specific, but all transports will return a new
http object that provides credentials to requests and refreshed credentials
when a response in REFRESH_STATUS_CODES is received.

This comment was marked as spam.

This comment was marked as spam.

The arguments match :func:`oauth2client.transport.request`. Additional
arguments are passed through to
:meth:`urllib3.request.RequestMethods.request`.

This comment was marked as spam.

This comment was marked as spam.

urllib3.response.HTTPResponse: The HTTP response.
"""
response = http.request(method, uri, body=body, headers=headers, **kwargs)
return response

This comment was marked as spam.

This comment was marked as spam.

@@ -24,7 +24,7 @@
NXDOMAIN = 'test.invalid'


def test_server_app():
def server_app():

This comment was marked as spam.

This comment was marked as spam.


import urllib3
import urllib3.exceptions
import mock

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@dhermes dhermes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@theacodes theacodes merged commit 1ac4645 into googleapis:transport-refactor Sep 26, 2016
@theacodes theacodes deleted the tr-4-urllib3-transport branch September 26, 2016 20:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants