http3: add compatibility with net/http.ResponseController (#3790)

* feat: compatibility with "net/http".ResponseController

* better deadline tests

* don't run deadline tests on Go 1.19

* skip deadline tests on Go 1.19
This commit is contained in:
Kévin Dunglas 2023-05-01 13:40:33 +02:00 committed by GitHub
parent 4a2a5740b2
commit 172123c340
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 129 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"bytes"
"io"
"net/http"
"time"
mockquic "github.com/quic-go/quic-go/internal/mocks/quic"
"github.com/quic-go/quic-go/internal/utils"
@ -25,6 +26,8 @@ var _ = Describe("Response Writer", func() {
strBuf = &bytes.Buffer{}
str := mockquic.NewMockStream(mockCtrl)
str.EXPECT().Write(gomock.Any()).DoAndReturn(strBuf.Write).AnyTimes()
str.EXPECT().SetReadDeadline(gomock.Any()).Return(nil).AnyTimes()
str.EXPECT().SetWriteDeadline(gomock.Any()).Return(nil).AnyTimes()
rw = newResponseWriter(str, nil, utils.DefaultLogger)
})
@ -156,4 +159,9 @@ var _ = Describe("Response Writer", func() {
fields := decodeHeader(strBuf)
Expect(fields).To(HaveKeyWithValue("content-type", []string{"text/html; charset=utf-8"}))
})
It(`is compatible with "net/http".ResponseController`, func() {
Expect(rw.SetReadDeadline(time.Now().Add(1 * time.Second))).To(BeNil())
Expect(rw.SetWriteDeadline(time.Now().Add(1 * time.Second))).To(BeNil())
})
})