forked from quic-go/quic-go
http3: automatically add content-length for small responses (#3989)
* response writer: add content-length automatically when response is small enough and doesn't call Flush * fix comment * add integration test * Update http3/response_writer.go * Update integrationtests/self/http_test.go --------- Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
@@ -128,6 +128,18 @@ var _ = Describe("HTTP tests", func() {
|
||||
Expect(string(body)).To(Equal("Hello, World!\n"))
|
||||
})
|
||||
|
||||
It("sets content-length for small response", func() {
|
||||
mux.HandleFunc("/small", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer GinkgoRecover()
|
||||
w.Write([]byte("foobar"))
|
||||
})
|
||||
|
||||
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/small", port))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp.StatusCode).To(Equal(200))
|
||||
Expect(resp.Header.Get("Content-Length")).To(Equal(strconv.Itoa(len("foobar"))))
|
||||
})
|
||||
|
||||
It("requests to different servers with the same udpconn", func() {
|
||||
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/remoteAddr", port))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Reference in New Issue
Block a user