forked from quic-go/quic-go
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:
@@ -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
|
||||
|
||||
1785
http3/client_test.go
1785
http3/client_test.go
File diff suppressed because it is too large
Load Diff
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user