http3: implement on the HTTPStreamer on the ResponseWriter, flush header (#4469)

Currently the HTTPStreamer is implemented on the http.Request.Body. This
complicates usage, since it's not easily possible to flush the HTTP
header, requiring users to manually flash the header before taking over
the stream.

With this change, the HTTP header is now flushed automatically as soon
as HTTPStream is called.
This commit is contained in:
Marten Seemann
2024-04-27 13:30:39 +02:00
committed by GitHub
parent 083ceb42f2
commit 34f4d1443f
5 changed files with 40 additions and 30 deletions

View File

@@ -422,9 +422,8 @@ var _ = Describe("HTTP tests", func() {
defer GinkgoRecover()
close(handlerCalled)
w.WriteHeader(http.StatusOK)
w.(http.Flusher).Flush()
str := r.Body.(http3.HTTPStreamer).HTTPStream()
str := w.(http3.HTTPStreamer).HTTPStream()
str.Write([]byte("foobar"))
// Do this in a Go routine, so that the handler returns early.
@@ -734,9 +733,8 @@ var _ = Describe("HTTP tests", func() {
Eventually(conn.ReceivedSettings()).Should(BeClosed())
Expect(conn.Settings().EnableDatagrams).To(BeTrue())
w.WriteHeader(http.StatusOK)
w.(http.Flusher).Flush()
str := r.Body.(http3.HTTPStreamer).HTTPStream()
str := w.(http3.HTTPStreamer).HTTPStream()
go str.Read([]byte{0}) // need to continue reading from stream to observe state transitions
for {