[net] internal/http3: more robust handling of request & response with no body

0 views
Skip to first unread message

Nicholas Husin (Gerrit)

unread,
Feb 9, 2026, 2:17:21 PMFeb 9
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Nicholas Husin, Damien Neil, Go LUCI, golang-co...@googlegroups.com

Nicholas Husin submitted the change

Change information

Commit message:
internal/http3: more robust handling of request & response with no body

In HTTP/3, zero or more DATA frames can come after a HEADERS frame to
represent a request or response body. Our current implementation can
behave rather badly when zero DATA frame is sent.

ClientConn does not close the write direction of the stream when it has
no body to send. As a result, our Server can end up reading the next
frame after a HEADERS frame, only to hang infinitely until the timeout
is reached. To fix this, when there is no body to send, ClientConn now
closes the write direction of the stream as soon as it has finished
writing its HEADERS frame. Server will also prevent itself from reading
the stream if a Content-Length header with the value 0 is received.

In the opposite direction (client reading response from a server), a
similar problem also exists, with a slight variant. While our Server
reliably closes its write direction of the stream as soon as the server
handler exits, a problem can still occur when a client receives an empty
response body due to sending a HEAD request. In this case, if the client
decides to read the response body, bodyReader might throw an error due
to a mismatch between the Content-Length header given by the server and
the actual body length. This is fixed by making ClientConn aware that
HEAD requests will always result in an empty response body.

For golang/go#70914
Change-Id: I1e8970672e7076c9dbf84aec8808632d04bac807
Reviewed-by: Damien Neil <dn...@google.com>
Reviewed-by: Nicholas Husin <hu...@google.com>
Files:
  • M internal/http3/roundtrip.go
  • M internal/http3/roundtrip_test.go
  • M internal/http3/server.go
  • M internal/http3/server_test.go
Change size: M
Delta: 4 files changed, 127 insertions(+), 8 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Damien Neil, +1 by Nicholas Husin
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: net
Gerrit-Branch: master
Gerrit-Change-Id: I1e8970672e7076c9dbf84aec8808632d04bac807
Gerrit-Change-Number: 742960
Gerrit-PatchSet: 3
Gerrit-Owner: Nicholas Husin <n...@golang.org>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Nicholas Husin <hu...@google.com>
Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages