Replies: 1 comment 2 replies
-
At this point in time it'd be a "no" from me. I don't really want us to consider extending any API past the boundaries that parity-with-requests gives us, until we're past 1.0. (Unless there's some very compelling reason to do so.) Note that you can already do the following... r = httpx.get('http://....').raise_for_status().json() Which is functionally pretty much the same example use-case you've given, but just a slightly different syntax to achieve it. I can imagine that there might be something here for us to explore in the future. For example, I can see something like the following might fit in well with our existing API... client = httpx.Client(raise_for_status=True) # A client instance that automatically calls `raise_for_status()` on responses.
r = client.get('http://....').json() |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
I would like to be able to send an HTTP request, check response error codes, and read the results with a single expression. Currently, for this purpose, I most often create utilities function:
I think, that this is such a common pattern that it would be worth simplifying it in the library itself.
To do this, we can add another check parameter, which will cause the
raise_for_status
function to be called before the result is returned. This will allow us to download a simple JSON file in one line while still handling exceptional situations.This will be in line with the assumptions of the standard library -
subprocess.run
, so it will make using this library even easier. Developers will not have to learn about an additional method in the inner class.Best regards,
Kamil Breguła
Beta Was this translation helpful? Give feedback.
All reactions