Skip to content

Bidirectional streaming #528

Answered by tomchristie
benblack769 asked this question in Q&A
Mar 31, 2022 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

You're looking for the network_stream extension...

https://www.encode.io/httpcore/extensions/#network_stream

That'll give you a read/write interface directly onto either the TCP connection (HTTP/1.1) or onto an individual HTTP/2 stream.

I'd recommend that you start out by giving it a go from httpcore directly, and then switch up to using it with httpx once you're confident you've got everything working...

url = httpcore.URL(b"http", b"127.0.0.1", 8080, b"http://www.example.com")
with httpcore.stream("POST", url) as response:
    network_stream = response.extensions["network_stream"]
    ...

We documented it for "CONNECT" method requests and requests using the Upgrade header. It should als…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@benblack769
Comment options

@benblack769
Comment options

@benblack769
Comment options

@tomchristie
Comment options

@benblack769
Comment options

Answer selected by benblack769
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
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #527 on March 31, 2022 07:54.