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

Use httpx instead of requests #360

Open
lemon24 opened this issue Nov 1, 2024 · 3 comments
Open

Use httpx instead of requests #360

lemon24 opened this issue Nov 1, 2024 · 3 comments

Comments

@lemon24
Copy link
Owner

lemon24 commented Nov 1, 2024

Requests is great and battle-tested, but suffers from a number of issues, which may never get fixed due to feature freeze:

Bad reasons to move away from Requests:

  • lack of async support – I have no plan for reader async support at this point
  • lack of support for Brotli/Zstandard encodings – urllib3 does support them

Reasons to move to httpx:

  • largely Requests-compatible API
  • while the ecosystem is probably not comparable, the basics (mocking, auth) are there
  • default timeouts (and more kinds than Requests has)
  • requests/response hooks (the writable response.next_request attribute should allow for hooks to trigger retries, which should allow getting rid of SessionWrapper entirely)
  • URL normalization
  • HTTP2 support (but I don't think we're in any hurry for this)

Reasons to not move to httpx:

  • not 1.0 yet (but coming soon)
  • not as battle-tested as Requests (but can support urllib3 if needed)

Important: Under no circumstances will reader support both Requests and httpx – the entire point of using a high level library like this is to have a single abstraction.

@lemon24 lemon24 changed the title Consider using httpx instead of requests Use httpx instead of requests Nov 1, 2024
@Ousret
Copy link

Ousret commented Nov 14, 2024

Probably unexpected,
but I would present another alternative. Namely Niquests.

It's a drop-in replacement for Requests. We took what was established and proven; only to extend its capabilities.
Almost every plugin (aka. extension like requests_mock) work the same.

You mentioned some pros/cons, I would present them as follow for Niquests:

  • Completely Requests-compatible API
  • Almost every plugins/extensions from Requests era are usable
  • default timeouts
  • HTTP/2 and HTTP/3 done effortlessly
  • stable API (not 0.x ver)
  • extended hooks available, like pre_request
  • fix a ton of issues from Requests era
  • Kept every bit of tests from Requests x urllib3 to ensure highest compat and reliability

This will produce a patch that will (i) simplify your code (ii) have a true upgrade from Requests.

Regards,

@lemon24
Copy link
Owner Author

lemon24 commented Nov 18, 2024

Hi @Ousret, Niquests looks very interesting, I will consider it when I start working on this issue; thank you!

@Ousret
Copy link

Ousret commented Nov 18, 2024

Don't hesitate to ping us if you need anything. We can assist.

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