question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some API oddities/possible oversights

See original GitHub issue

While I was working on porting my google-music library to httpx using pared down oauth2 code borrowed from requests-oauthlib (see the quick stab at it here if interested), I noticed some API oddities/differences from requests even with the relatively small amount of usage in my library.

  • BasicAuthMiddleware, previously HTTPBasicAuth, is not available at the top level of the package, nor any other middleware aside from DigestAuth. The current naming inconsistency between the two is also strange. Both are middleware, and it was named HTTPBasicAuth in requests and previously in httpx. Though I could certainly see the inconsistency being DigestAuth as all other middleware, including CustomAuthMiddleware, follow the same pattern. I think something needs to happen as far as the exposing, organizing, and making consistent of things like this. What that thing is, I’m not sure. Quick opinion is that these classes being middleware is more of an implementation detail than anything else. I’d expect the auth classes to be exposed through auth like previously and in requests or at the top level. I’d also expect them without “Middleware” in the names (possibly just aliased).

  • HTTPError is not available at the top level like the other exceptions and like it was in requests. This is a somewhat common exception to catch raise_for_status, so having to add another import statement for it is a bit odd if intentional.

  • requests.Session has a params attribute that attaches those params to each session request. This is not present in httpx Client classes like with headers/cookies. This is a useful feature for this and other use cases of mine and a divergence from requests.

Thanks for all the work. Been excited about httpx since the beginning. Glad to finally start using it more. Interested in seeing the discussion around these points.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
florimondmancacommented, Nov 22, 2019

@subfxnet There aren’t current plans to make it public, no, as we might be heavily reworking this part of HTTPX soon. I believe this is something we’d like to eventually provide, though.

1reaction
StephenBrown2commented, Sep 23, 2019

Aliasing but raising a DeprecationError for the aliases with a link to the migration docs would be a good middle path to take IMHO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found