Skip to content

Why does stream not return a file-like object (this breaks compatibility) #2296

Discussion options

You must be logged in to vote

Is the following code what you want

with httpx.stream("GET", "https://example.com/") as response:
    raw_stream = response.extensions["network_stream"]
    print(raw_stream.read(2))
# b'\x1f\x8b'

print(requests.get("https://example.com/", stream=True).raw.read(2))
# b'\x1f\x8b'

Replies: 4 comments 12 replies

Comment options

You must be logged in to vote
10 replies
@tomchristie
Comment options

@jacksbox
Comment options

@tomchristie
Comment options

@jacksbox
Comment options

@tomchristie
Comment options

Comment options

You must be logged in to vote
2 replies
@zanieb
Comment options

@tomchristie
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by tomchristie
Comment options

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