Merge pull request #2166 from juliens/alt-svc

Fix Alt-Svc header
This commit is contained in:
Marten Seemann
2019-10-14 05:17:25 +07:00
committed by GitHub
3 changed files with 4 additions and 4 deletions

View File

@@ -334,7 +334,7 @@ func (s *Server) SetQuicHeaders(hdr http.Header) error {
s.supportedVersionsAsString = strings.Join(versions, ",")
}
hdr.Add("Alt-Svc", fmt.Sprintf(`quic=":%d"; ma=2592000; v="%s"`, port, s.supportedVersionsAsString))
hdr.Add("Alt-Svc", fmt.Sprintf(`%s=":%d"; ma=2592000; quic="%s"`, nextProtoH3, port, s.supportedVersionsAsString))
return nil
}

View File

@@ -334,12 +334,12 @@ var _ = Describe("Server", func() {
versionsAsString = append(versionsAsString, v.ToAltSvc())
}
return http.Header{
"Alt-Svc": {fmt.Sprintf(`quic=":443"; ma=2592000; v="%s"`, strings.Join(versionsAsString, ","))},
"Alt-Svc": {fmt.Sprintf(`%s=":443"; ma=2592000; quic="%s"`, nextProtoH3, strings.Join(versionsAsString, ","))},
}
}
BeforeEach(func() {
Expect(getExpectedHeader([]protocol.VersionNumber{99, 90, 9})).To(Equal(http.Header{"Alt-Svc": {`quic=":443"; ma=2592000; v="99,90,9"`}}))
Expect(getExpectedHeader([]protocol.VersionNumber{0x00000001, 0x1abadaba})).To(Equal(http.Header{"Alt-Svc": {nextProtoH3 + `=":443"; ma=2592000; quic="1,1abadaba"`}}))
expected = getExpectedHeader(protocol.SupportedVersions)
})

View File

@@ -50,7 +50,7 @@ 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("%d", vn)
return fmt.Sprintf("%x", uint32(vn))
}
func (vn VersionNumber) isGQUIC() bool {