Skip to content
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

Support alternate HTTP client libraries, like httpx #141

Open
kevinlul opened this issue Apr 17, 2023 · 1 comment
Open

Support alternate HTTP client libraries, like httpx #141

kevinlul opened this issue Apr 17, 2023 · 1 comment

Comments

@kevinlul
Copy link

kevinlul commented Apr 17, 2023

Describe the solution you'd like

prawcore is currently tied to requests and asyncprawcore to aiohttp. I like how httpx has both async and sync capabilities and would like to use one HTTP library in my project as I will be calling other APIs as well. I would also like to see if httpx's HTTP/2 implementation provides any latency improvement over HTTP/1.1 implementations.

httpx is broadly compatible with requests but httpx.Client does not implement the exact API as requests.Session: https://www.python-httpx.org/compatibility/

Naively constructing praw.Reddit with requestor_kwargs={"session": client} where client = Client(http2=True), I was able to run praw's quickstart example listing 10 hot submissions with the below two patches:

data=sorted(data.items()),

replace with data=data, httpx only supports dict syntax and not a list of tuples

allow_redirects=False,

remove entirely, as httpx names the parameter differently and defaults to no redirects anyway

Describe alternatives you've considered

No response

Additional context

https://praw.slack.com/archives/CRZ00QLC9/p1681666057106319

@Ousret
Copy link

Ousret commented Dec 6, 2023

Hello there,

Sorry to barge in,
There's an alternative you may be interested in. https://github.com/jawah/niquests

This is a drop-in-worthy replacement for Requests that ships with modern capabilities and allows you a painless transition.
I can answer any concerns you may have.

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

No branches or pull requests

2 participants