Skip to content

Add HTTP/1.x bidi streaming support#913

Open
emcfarlane wants to merge 9 commits intomainfrom
ed/http1BidiStream
Open

Add HTTP/1.x bidi streaming support#913
emcfarlane wants to merge 9 commits intomainfrom
ed/http1BidiStream

Conversation

@emcfarlane
Copy link
Copy Markdown
Contributor

@emcfarlane emcfarlane commented Mar 12, 2026

This adds support for bidi streaming over HTTP/1 connections. It's an improvement over #796 adding support for full-duplex streams. It makes use of the new ResponseControler.EnableFullDuplex method to enable support. If disabled, this returns an error and we report the same error as previously. If enabled, the bidi connection is now allowed.

To test bidi streams over HTTP/1 memhttp is updated to use a buffered conn. WIth an unbuffered conn, both sides of the net.Pipe are stuck writing, and neither can read because the write is synchronous and blocking. With real TCP sockets, the kernel buffers absorb these writes and there's no deadlock. This better imitates a real conn implementation. Follows the approach taken in: https://go-review.googlesource.com/c/go/+/740100

Closes #872

Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
On an end of stream message, if the connection fails during drain but no
bytes were read, prefer the error from the envelope.

Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
Comment thread envelope.go
if connErr, ok := asError(err); ok {
return connErr
}
return errorf(CodeInternal, "corrupt response: I/O error after end-stream message: %w", err)
Copy link
Copy Markdown
Contributor Author

@emcfarlane emcfarlane Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reported the following error in the testcase TestClientBidiOverHTTP1/cumsum_error:

internal: corrupt response: I/O error after end-stream message: read tcp 127.0.0.1:61157->127.0.0.1:60942: wsarecv: An existing connection was forcibly closed by the remote host.

Fixed in: b5db2ac

Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
@emcfarlane emcfarlane marked this pull request as draft April 2, 2026 16:03
Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
@emcfarlane emcfarlane force-pushed the ed/http1BidiStream branch from e4e684a to ed304d1 Compare April 9, 2026 13:35
Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
@emcfarlane emcfarlane marked this pull request as ready for review April 21, 2026 14:54
Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant