forked from quic-go/quic-go
rename the h2quic.QuicRoundTripper to h2quic.RoundTripper
This commit is contained in:
@@ -11,8 +11,8 @@ import (
|
||||
"golang.org/x/net/lex/httplex"
|
||||
)
|
||||
|
||||
// QuicRoundTripper implements the http.RoundTripper interface
|
||||
type QuicRoundTripper struct {
|
||||
// RoundTripper implements the http.RoundTripper interface
|
||||
type RoundTripper struct {
|
||||
mutex sync.Mutex
|
||||
|
||||
// DisableCompression, if true, prevents the Transport from
|
||||
@@ -32,10 +32,10 @@ type QuicRoundTripper struct {
|
||||
clients map[string]http.RoundTripper
|
||||
}
|
||||
|
||||
var _ http.RoundTripper = &QuicRoundTripper{}
|
||||
var _ http.RoundTripper = &RoundTripper{}
|
||||
|
||||
// RoundTrip does a round trip
|
||||
func (r *QuicRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
func (r *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
if req.URL == nil {
|
||||
closeRequestBody(req)
|
||||
return nil, errors.New("quic: nil Request.URL")
|
||||
@@ -74,7 +74,7 @@ func (r *QuicRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
return r.getClient(hostname).RoundTrip(req)
|
||||
}
|
||||
|
||||
func (r *QuicRoundTripper) getClient(hostname string) http.RoundTripper {
|
||||
func (r *RoundTripper) getClient(hostname string) http.RoundTripper {
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type mockQuicRoundTripper struct{}
|
||||
type mockRoundTripper struct{}
|
||||
|
||||
func (m *mockQuicRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
func (m *mockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return &http.Response{Request: req}, nil
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ var _ io.ReadCloser = &mockBody{}
|
||||
|
||||
var _ = Describe("RoundTripper", func() {
|
||||
var (
|
||||
rt *QuicRoundTripper
|
||||
rt *RoundTripper
|
||||
req1 *http.Request
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
rt = &QuicRoundTripper{}
|
||||
rt = &RoundTripper{}
|
||||
var err error
|
||||
req1, err = http.NewRequest("GET", "https://www.example.org/file1.html", nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -56,7 +56,7 @@ var _ = Describe("RoundTripper", func() {
|
||||
|
||||
It("reuses existing clients", func() {
|
||||
rt.clients = make(map[string]http.RoundTripper)
|
||||
rt.clients["www.example.org:443"] = &mockQuicRoundTripper{}
|
||||
rt.clients["www.example.org:443"] = &mockRoundTripper{}
|
||||
rsp, err := rt.RoundTrip(req1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(rsp.Request).To(Equal(req1))
|
||||
|
||||
Reference in New Issue
Block a user