don't pass the roundtripper to the h2quic client

This commit is contained in:
Marten Seemann
2017-06-02 22:35:16 +02:00
parent 4c3d4960bb
commit 9054e5205f
4 changed files with 21 additions and 30 deletions

View File

@@ -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) }()