From f110af917b5795eb1c548f90bddc35a35c283197 Mon Sep 17 00:00:00 2001 From: Julien Salleyron Date: Mon, 21 Oct 2019 17:18:02 +0200 Subject: [PATCH] Remove QUIC version hint --- http3/server.go | 14 +------------- http3/server_test.go | 14 ++++---------- internal/protocol/version.go | 5 ----- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/http3/server.go b/http3/server.go index b1f96ed0..4610e424 100644 --- a/http3/server.go +++ b/http3/server.go @@ -10,13 +10,11 @@ import ( "net" "net/http" "runtime" - "strings" "sync" "sync/atomic" "time" "github.com/lucas-clemente/quic-go" - "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/utils" "github.com/marten-seemann/qpack" "github.com/onsi/ginkgo" @@ -58,8 +56,6 @@ type Server struct { listeners map[*quic.Listener]struct{} closed utils.AtomicBool - supportedVersionsAsString string - logger utils.Logger } @@ -326,15 +322,7 @@ func (s *Server) SetQuicHeaders(hdr http.Header) error { atomic.StoreUint32(&s.port, port) } - if s.supportedVersionsAsString == "" { - var versions []string - for _, v := range protocol.SupportedVersions { - versions = append(versions, v.ToAltSvc()) - } - s.supportedVersionsAsString = strings.Join(versions, ",") - } - - hdr.Add("Alt-Svc", fmt.Sprintf(`%s=":%d"; ma=2592000; quic="%s"`, nextProtoH3, port, s.supportedVersionsAsString)) + hdr.Add("Alt-Svc", fmt.Sprintf(`%s=":%d"; ma=2592000`, nextProtoH3, port)) return nil } diff --git a/http3/server_test.go b/http3/server_test.go index eec52ad3..7a6f4aa6 100644 --- a/http3/server_test.go +++ b/http3/server_test.go @@ -9,13 +9,11 @@ import ( "io" "net" "net/http" - "strings" "time" "github.com/golang/mock/gomock" "github.com/lucas-clemente/quic-go" mockquic "github.com/lucas-clemente/quic-go/internal/mocks/quic" - "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/testdata" "github.com/lucas-clemente/quic-go/internal/utils" "github.com/marten-seemann/qpack" @@ -328,19 +326,15 @@ var _ = Describe("Server", func() { Context("setting http headers", func() { var expected http.Header - getExpectedHeader := func(versions []protocol.VersionNumber) http.Header { - var versionsAsString []string - for _, v := range versions { - versionsAsString = append(versionsAsString, v.ToAltSvc()) - } + getExpectedHeader := func() http.Header { return http.Header{ - "Alt-Svc": {fmt.Sprintf(`%s=":443"; ma=2592000; quic="%s"`, nextProtoH3, strings.Join(versionsAsString, ","))}, + "Alt-Svc": {fmt.Sprintf(`%s=":443"; ma=2592000`, nextProtoH3)}, } } BeforeEach(func() { - Expect(getExpectedHeader([]protocol.VersionNumber{0x00000001, 0x1abadaba})).To(Equal(http.Header{"Alt-Svc": {nextProtoH3 + `=":443"; ma=2592000; quic="1,1abadaba"`}})) - expected = getExpectedHeader(protocol.SupportedVersions) + Expect(getExpectedHeader()).To(Equal(http.Header{"Alt-Svc": {nextProtoH3 + `=":443"; ma=2592000`}})) + expected = getExpectedHeader() }) It("sets proper headers with numeric port", func() { diff --git a/internal/protocol/version.go b/internal/protocol/version.go index 69ccbe48..20c4d7d0 100644 --- a/internal/protocol/version.go +++ b/internal/protocol/version.go @@ -48,11 +48,6 @@ func (vn VersionNumber) String() string { } } -// ToAltSvc returns the representation of the version for the H2 Alt-Svc parameters -func (vn VersionNumber) ToAltSvc() string { - return fmt.Sprintf("%x", uint32(vn)) -} - func (vn VersionNumber) isGQUIC() bool { return vn > gquicVersion0 && vn <= maxGquicVersion }