-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discussion] HTTP library #1346
Comments
As a start, it'd be nice to
>>> http = httplib2.Http()
>>> auth_http = credentials.authorize(http)
>>> auth_http
<oauth2client.transport.AuthenticatedHttp at 0x00deadbeaf00> and |
What I would prefer even more: >>> auth_http = AuthenticatedHttp(credentials)
>>> auth_http
<oauth2client.transport.AuthenticatedHttp at 0x00deadbeaf00> Which would allow something like: >>> auth_session = AuthenticatedSession(credentials)
>>> auth_session
<oauth2client.transport.requests.AuthenticatedSession at 0x00deadbeaf00> To be idiomatic. |
Does it make sense to have transports be a separate library all together? |
nvm, the refresh logic is very oauth-centric so it doesn't quite make sense. Though I am curious what special considerations we'll need to make to use those transports in this library. |
Wow, there's a ton of code in What's the utility in continuing to support httplib2 directly? Could we move to urllib3 and be better served? |
Your suggestion >>> auth_http = AuthenticatedHttp(credentials) is not agnostic of the transport. Instead you'd need >>> auth_http = AuthenticatedHttp(credentials, http) and you'd need a well-defined interface for |
Sorry, I may not have been clear: authed_transport = transports.httplib2.Transport(credentials)
authed_transport = transports.urllib3.Transport(credentials)
authed_transport = transports.requests.Transport(credentials) |
Got it. I think it'd be easier to have a simple default that can use a |
I'm not a fan of httplib2's interface, and I think we'd be doing ourselves a disservice if we tried to make that our definition for the future. Personally, I'd be in favor of dropping httplib2 altogether in favor of urllib3. Requests support would then be pretty straightforward. But that's pretty extreme and the waters for urllib3 and app engine are rocky. |
Now we're talking! 😀 Can you describe your desired interface? |
Not sure yet. :) Maybe something along the lines of how urllib3 does things already: the def urlopen(self, method, url, body=None, headers=None, retries=None,
redirect=True, assert_same_host=True, timeout=_Default,
pool_timeout=None, release_conn=None, **response_kw): Our transport for urllib3 could just be a wrapper around urlopen that does the authentication and refresh logic. Any other transport would need to implement the same urlopen interface. |
Maybe it's better to put it this way: I think it's fine to let urllib3's |
Very similar to def request(self, uri, method="GET", body=None, headers=None,
redirections=DEFAULT_MAX_REDIRECTS, connection_type=None): also def fetch(self, url, payload=None, method=1, headers={}, allow_truncated=False,
follow_redirects=True, deadline=None, validate_certificate=None): def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): and def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
cafile=None, capath=None, cadefault=False, context=None): |
I agree. I think it'd be nice just to allow someone to create any old transport they like and have it work with |
That's sort of the beauty of urllib3's design - the 'Manager' is the top-level component and there's currently multiple managers (e.g, ProxyManager, AppEngineManager, etc.). |
Seems like we agree on the interface part, but maybe not on the dependency bit. I'd like it to work without any assumption that the user has |
Considering requests (and by extension urllib3) are currently the 3rd most popular python package (above the package manager, even!) it doesn't seem like much of a stretch for us to use urrlib3 by default and say that anyone who wishes to use another transport should implement urllib3's PoolManager interface. We can even provide the existing AppEngineManager as an example. |
Yeah that may be the right route. (We should loop in |
So does our plan from here look like:
|
You don't think |
It should be, but I'm unsure. It's not as thoroughly tested as raw httplib2. Though the surface area is quite small. What do you think? |
Raw |
What are you feelings on replacing httplib2 wholesale with urllib3 in this library once oauth2client is ready? |
I'm fine with it. I have no allegiance to |
Fun fact: I wrote urllib3 partly because of very many httplib2-related issues in 2008. :P (Not much had changed.) |
Ha! Nice. I wish I would've known in 2011 what I know now when I started working with the Google client libraries. @jonparrott I've already filed googleapis/oauth2client#128 for the |
Prototype coming anytime soon? |
Going through OSS process now. It will live at On Wed, Jan 20, 2016, 5:57 PM Danny Hermes notifications@github.com wrote:
|
👍 |
httplib2shim has been published. @dhermes what do you think we should do from here? My initial thoughts:
|
Thanks for the heads-up! I think we should attack |
What are you ideas for |
I have the same issue. |
@ds-hwang Feel free to give httplib2shim a go and report any issues. |
I think httplib2shim is fine. |
Update: This library now uses We still need a plan of attack for removing httplib2 as the transport here, but we no longer have a hard dependency on it. |
hi all, i appreciate that this issue is being more broadly discussed and will be fixed with #1346. but we've been seeing this issue for a couple years now and it really hasn't been documented at a very visible level, which would have helped when we first ran into this.
but on the subsequent retries, they failed (our application logic) because the file had evidently been uploaded and this error occurred after the successful upload on the first try. |
What's the current status of thread-safety in the python APIs? #1214 was closed and redirected to this issue, but it'd be nice to have a clearer explanation of what's going on in this issue with respect to thread safety. FWIW https://developers.google.com/api-client-library/python/guide/thread_safety still mentions only httplib2 and a somewhat cumbersome workaround to ensure thread safety. |
Hi @asilversempirical: |
@lukesneeringer I'd guess that issue was #1998 |
Okay. Let's keep that one and close this one. |
Thanks for the pointer! |
Presently, we use httplib2 by default but allow users to specify their own http library (#908) so long as it conforms to
httplib2.Http
's signature.httplib2 was chosen because it's the underlying http client used by google/oauth2client. However, httplib2 has a variety of issues include not being thread-safe (#1274), not doing any connection pooling, etc.
We should consider what it would take to move to another http library. The major considerations are:
The text was updated successfully, but these errors were encountered: