forked from quic-go/quic-go
don't pass the roundtripper to the h2quic client
This commit is contained in:
@@ -20,16 +20,14 @@ import (
|
||||
|
||||
var _ = Describe("Client", func() {
|
||||
var (
|
||||
client *client
|
||||
session *mockSession
|
||||
headerStream *mockStream
|
||||
quicTransport *QuicRoundTripper
|
||||
client *client
|
||||
session *mockSession
|
||||
headerStream *mockStream
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
quicTransport = &QuicRoundTripper{}
|
||||
hostname := "quic.clemente.io:1337"
|
||||
client = newClient(quicTransport, nil, hostname)
|
||||
client = newClient(nil, hostname, &roundTripperOpts{})
|
||||
Expect(client.hostname).To(Equal(hostname))
|
||||
session = &mockSession{}
|
||||
client.session = session
|
||||
@@ -41,17 +39,17 @@ var _ = Describe("Client", func() {
|
||||
|
||||
It("saves the TLS config", func() {
|
||||
tlsConf := &tls.Config{InsecureSkipVerify: true}
|
||||
client = newClient(&QuicRoundTripper{}, tlsConf, "")
|
||||
client = newClient(tlsConf, "", &roundTripperOpts{})
|
||||
Expect(client.config.TLSConfig).To(Equal(tlsConf))
|
||||
})
|
||||
|
||||
It("adds the port to the hostname, if none is given", func() {
|
||||
client = newClient(quicTransport, nil, "quic.clemente.io")
|
||||
client = newClient(nil, "quic.clemente.io", &roundTripperOpts{})
|
||||
Expect(client.hostname).To(Equal("quic.clemente.io:443"))
|
||||
})
|
||||
|
||||
It("dials", func() {
|
||||
client = newClient(quicTransport, nil, "localhost")
|
||||
client = newClient(nil, "localhost", &roundTripperOpts{})
|
||||
session.streamToOpen = &mockStream{id: 3}
|
||||
client.dialAddr = func(hostname string, conf *quic.Config) (quic.Session, error) {
|
||||
return session, nil
|
||||
@@ -63,7 +61,7 @@ var _ = Describe("Client", func() {
|
||||
|
||||
It("errors when dialing fails", func() {
|
||||
testErr := errors.New("handshake error")
|
||||
client = newClient(quicTransport, nil, "localhost")
|
||||
client = newClient(nil, "localhost", &roundTripperOpts{})
|
||||
client.dialAddr = func(hostname string, conf *quic.Config) (quic.Session, error) {
|
||||
return nil, testErr
|
||||
}
|
||||
@@ -72,7 +70,7 @@ var _ = Describe("Client", func() {
|
||||
})
|
||||
|
||||
It("errors if the header stream has the wrong stream ID", func() {
|
||||
client = newClient(quicTransport, nil, "localhost")
|
||||
client = newClient(nil, "localhost", &roundTripperOpts{})
|
||||
session.streamToOpen = &mockStream{id: 2}
|
||||
client.dialAddr = func(hostname string, conf *quic.Config) (quic.Session, error) {
|
||||
return session, nil
|
||||
@@ -83,7 +81,7 @@ var _ = Describe("Client", func() {
|
||||
|
||||
It("errors if it can't open a stream", func() {
|
||||
testErr := errors.New("you shall not pass")
|
||||
client = newClient(quicTransport, nil, "localhost")
|
||||
client = newClient(nil, "localhost", &roundTripperOpts{})
|
||||
session.streamOpenErr = testErr
|
||||
client.dialAddr = func(hostname string, conf *quic.Config) (quic.Session, error) {
|
||||
return session, nil
|
||||
@@ -226,7 +224,7 @@ var _ = Describe("Client", func() {
|
||||
|
||||
It("adds the port for request URLs without one", func(done Done) {
|
||||
var err error
|
||||
client = newClient(quicTransport, nil, "quic.clemente.io")
|
||||
client = newClient(nil, "quic.clemente.io", &roundTripperOpts{})
|
||||
req, err := http.NewRequest("https", "https://quic.clemente.io/foobar.html", nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
@@ -365,7 +363,7 @@ var _ = Describe("Client", func() {
|
||||
})
|
||||
|
||||
It("doesn't add gzip if the header disable it", func() {
|
||||
quicTransport.DisableCompression = true
|
||||
client.opts.DisableCompression = true
|
||||
var doErr error
|
||||
go func() { _, doErr = client.Do(request) }()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user