http3: migrate the client tests away from Ginkgo (#5096)

* http3: migrate the client tests away from Ginkgo

* http3: add a client settings test
This commit is contained in:
Marten Seemann
2025-05-10 11:24:21 +08:00
committed by GitHub
parent 8474eddd3a
commit 3f97a011a7
3 changed files with 715 additions and 1090 deletions

View File

@@ -32,6 +32,8 @@ const (
defaultMaxResponseHeaderBytes = 10 * 1 << 20 // 10 MB
)
const max1xxResponses = 5 // arbitrary bound on number of informational responses
var defaultQuicConfig = &quic.Config{
MaxIncomingStreams: -1, // don't allow the server to create bidirectional streams
KeepAlivePeriod: 10 * time.Second,
@@ -323,9 +325,7 @@ func (c *ClientConn) doRequest(req *http.Request, str *requestStream) (*http.Res
}
// copy from net/http: support 1xx responses
num1xx := 0 // number of informational 1xx headers received
const max1xxResponses = 5 // arbitrary bound on number of informational responses
var num1xx int // number of informational 1xx headers received
var res *http.Response
for {
var err error
@@ -340,10 +340,10 @@ func (c *ClientConn) doRequest(req *http.Request, str *requestStream) (*http.Res
if is1xxNonTerminal {
num1xx++
if num1xx > max1xxResponses {
return nil, errors.New("http: too many 1xx informational responses")
return nil, errors.New("http3: too many 1xx informational responses")
}
traceGot1xxResponse(trace, resCode, textproto.MIMEHeader(res.Header))
if resCode == 100 {
if resCode == http.StatusContinue {
traceGot100Continue(trace)
}
continue

File diff suppressed because it is too large Load Diff

View File

@@ -184,6 +184,16 @@ var _ = Describe("Request Stream", func() {
})
It("reads after the response", func() {
encodeResponse := func(status int) []byte {
buf := &bytes.Buffer{}
rstr := mockquic.NewMockStream(mockCtrl)
rstr.EXPECT().Write(gomock.Any()).Do(buf.Write).AnyTimes()
rw := newResponseWriter(newStream(rstr, nil, nil, func(r io.Reader, u uint64) error { return nil }), nil, false, nil)
rw.WriteHeader(status)
rw.Flush()
return buf.Bytes()
}
req, err := http.NewRequest(http.MethodGet, "https://quic-go.net", nil)
Expect(err).ToNot(HaveOccurred())
qstr.EXPECT().Write(gomock.Any()).AnyTimes()