Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion httpcore/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def stream(

When using the `stream()` function, the body of the response will not be
automatically read. If you want to access the response body you should
either use `content = response.read()`, or `for chunk in response.iter_content()`.
either use `content = response.read()`, or `for chunk in response.iter_stream()`.

Arguments:
method: The HTTP method for the request. Typically one of `"GET"`,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ def test_response():
assert repr(response.stream) == "<ByteStream [0 bytes]>"


def test_response_streaming_api_names():
# The public docstrings (e.g. `httpcore.stream()`) tell users to read a
# streamed body with `response.read()` or `for chunk in response.iter_stream()`.
# Pin those method names so the documented API cannot silently drift to a
# name that does not exist (doctests are not run in CI).
response = httpcore.Response(200)
assert hasattr(response, "read")
assert hasattr(response, "iter_stream")
assert hasattr(response, "aread")
assert hasattr(response, "aiter_stream")
assert not hasattr(response, "iter_content")


# Tests for reading and streaming sync byte streams...


Expand Down
Loading