reject http3 requests that exceeded the header size limit

This commit is contained in:
Marten Seemann
2019-08-22 10:23:51 +07:00
parent 2133d01956
commit 9294652ecc
2 changed files with 33 additions and 1 deletions

View File

@@ -181,6 +181,28 @@ var _ = Describe("Server", func() {
Expect(hfs).To(HaveKeyWithValue(":status", []string{"200"}))
})
It("errors when the client sends a too large header frame", func() {
s.Server.MaxHeaderBytes = 42
s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Fail("Handler should not be called.")
})
requestData := encodeRequest(exampleGetRequest)
buf := &bytes.Buffer{}
(&dataFrame{Length: 6}).Write(buf) // add a body
buf.Write([]byte("foobar"))
responseBuf := &bytes.Buffer{}
setRequest(append(requestData, buf.Bytes()...))
str.EXPECT().Write(gomock.Any()).DoAndReturn(func(p []byte) (int, error) {
return responseBuf.Write(p)
}).AnyTimes()
str.EXPECT().CancelWrite(quic.ErrorCode(errorLimitExceeded))
err := s.handleRequest(str, qpackDecoder)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Headers frame too large"))
})
It("cancels reading when the body of POST request is not read", func() {
handlerCalled := make(chan struct{})
s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {