Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Write a Requests adapter #19

Closed
Lukasa opened this issue Feb 16, 2014 · 13 comments
Closed

Write a Requests adapter #19

Lukasa opened this issue Feb 16, 2014 · 13 comments
Labels

Comments

@Lukasa
Copy link
Member

Lukasa commented Feb 16, 2014

As a shorter-term goal than getting into urllib3 (tracked by #18), let's try to get hyper some exposure by making it plug into Requests. This should lead to some really interesting experiments, e.g. running Twython over HTTP/2.0.

@Lukasa Lukasa added the Easy label Feb 16, 2014
@Lukasa
Copy link
Member Author

Lukasa commented Feb 16, 2014

By the way, @michaelhelmick, you may end up wanting to keep an eye on this issue, I plan to play with Twython a bit here.

@michaelhelmick
Copy link

👍 I'll help be a Guinea Pig :) just let me know if I can so anything. I need to get back to some open source stuff. Been keeping busy with work D:

@Lukasa
Copy link
Member Author

Lukasa commented Feb 16, 2014

So mostly this is fine, except for the fact that Twython relies on urllib3's transparent content decoding, which hyper doesn't have. Awkward.

@Lukasa
Copy link
Member Author

Lukasa commented Feb 16, 2014

Tracking that issue in #20.

@Lukasa
Copy link
Member Author

Lukasa commented Feb 16, 2014

Current draft adapter is on the requests_adapter branch. Not sure how best to test it yet.

@sigmavirus24
Copy link
Contributor

@Lukasa with the integration test fixtures?

@Lukasa
Copy link
Member Author

Lukasa commented Feb 16, 2014

That might be the way to go.

@Lukasa
Copy link
Member Author

Lukasa commented Feb 20, 2014

Alright, the adapter got checked in as part of 799e37e. It's been enhanced a few times since as well. @michaelhelmick, if you want to start messing about with it go ahead. I've confirmed in a quick local test file that it works in the basic case, as you can see below. Note that you'll need to install hyper from GitHub, not from PyPI, as I haven't done a new release yet.

from hyper.contrib import HTTP20Adapter
from twython import Twython

API_KEY = ...
API_SECRET = ...
ACCESS_TOKEN = ..
ACCESS_SECRET = ...

t = Twython(API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_SECRET)
a = HTTP20Adapter()
t.client.mount('https://www.twitter.com', a)
t.client.mount('https://twitter.com', a)
t.client.mount('https://api.twitter.com', a)

print(t.search(q='python'))

@Lukasa
Copy link
Member Author

Lukasa commented Feb 20, 2014

You can now get the Transport Adapter in v0.0.2 from PyPI. =)

@michaelhelmick
Copy link

I replied via email, but it never sent I guess.. haha.

👌 I'm not free until Saturday to test, but I'll be sure to make time to test then!

@michaelhelmick
Copy link

Just an update, I got sick from moving our office this past week (with rain and dust and everything) and didn't feel up to testing this. I'll try to test some stuff by mid-net week! Sorry!!

@Lukasa
Copy link
Member Author

Lukasa commented Feb 23, 2014

That's not a problem at all @michaelhelmick, there's no rush here. I'm doing some basic performance analysis today anyway. =)

@Lukasa
Copy link
Member Author

Lukasa commented Feb 23, 2014

With that said, I'm getting some insane numbers that don't make any sense to me. It seems that, in HTTP/1.1, we're receiving ten times as much data as we are in HTTP/2.0. I have a question: does Twython turn off the Accept-Encoding headers in Requests?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants