Skip to content

Raise for respone content type #1723

Answered by johtso
4bo asked this question in General
Discussion options

You must be logged in to vote

You could just make your requests in streaming mode and not read the content. https://www.python-httpx.org/quickstart/#streaming-responses

The last example in that section of the docs is basically your use case:

>>> with httpx.stream("GET", "https://www.example.com") as r:
...     if r.headers['Content-Length'] < TOO_LONG:
...         r.read()
...         print(r.text)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tomchristie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants