-
-
Notifications
You must be signed in to change notification settings - Fork 857
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
Add support for httpx.Response(content=..., text=..., html=..., json=...)
#1250
Conversation
@@ -95,21 +92,14 @@ def __iter__(self) -> typing.Iterator[bytes]: | |||
def __aiter__(self) -> typing.AsyncIterator[bytes]: | |||
raise RuntimeError("Attempted to call a async iterator on an sync stream.") | |||
|
|||
def close(self) -> None: | |||
if self.close_func is not None: | |||
self.close_func() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we don't really need close_func
on IteratorStream
/AsyncIteratorStream
anymore, which falls out from updating test cases to use Response(content=<bytes iterator>)
raise httpcore.NetworkError(exc) from exc | ||
|
||
def close(self) -> None: | ||
self._conn.release_conn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this module are redundant given #1182, but I've updated this all the same since this PR removes close_func
from our internal IteratorStream
.
0744e4d
to
266bfa1
Compare
httpx.Response(content=..., text=..., html=..., json=...)
If we need to narrow down the scope of this for review purposes, I'd be happy to think about how best to do that. |
Putting this in draft to instead tackle the intent here in a more targeted manner. |
Closing in favour of #1297 |
Closes #1227
Adds support for eg...
httpx.Response(200, content=b'Hello, world')
httpx.Response(200, text='Hello, world')
httpx.Response(200, html='Hello, world')
httpx.Response(200, json={'Hello': 'world'})
Plus streaming cases...
httpx.Response(200, content=<byte iterator>)
httpx.Response(200, content=<byte aiterator>)
There are some test cases we'd be able to smarten up after this, but I'll leave that for a follow up.