diff --git a/internal/wire/connection_close_frame.go b/internal/wire/connection_close_frame.go index 5d07760de..9a11a34c6 100644 --- a/internal/wire/connection_close_frame.go +++ b/internal/wire/connection_close_frame.go @@ -13,6 +13,7 @@ import ( type ConnectionCloseFrame struct { IsApplicationError bool ErrorCode qerr.ErrorCode + FrameType uint64 ReasonPhrase string } @@ -30,9 +31,11 @@ func parseConnectionCloseFrame(r *bytes.Reader, version protocol.VersionNumber) f.ErrorCode = qerr.ErrorCode(ec) // read the Frame Type, if this is not an application error if !f.IsApplicationError { - if _, err := utils.ReadVarInt(r); err != nil { + ft, err := utils.ReadVarInt(r) + if err != nil { return nil, err } + f.FrameType = ft } var reasonPhraseLen uint64 reasonPhraseLen, err = utils.ReadVarInt(r) @@ -73,7 +76,7 @@ func (f *ConnectionCloseFrame) Write(b *bytes.Buffer, version protocol.VersionNu utils.WriteVarInt(b, uint64(f.ErrorCode)) if !f.IsApplicationError { - utils.WriteVarInt(b, 0) + utils.WriteVarInt(b, f.FrameType) } utils.WriteVarInt(b, uint64(len(f.ReasonPhrase))) b.WriteString(f.ReasonPhrase) diff --git a/internal/wire/connection_close_frame_test.go b/internal/wire/connection_close_frame_test.go index 56a4620ee..0fbb3629b 100644 --- a/internal/wire/connection_close_frame_test.go +++ b/internal/wire/connection_close_frame_test.go @@ -25,6 +25,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() { Expect(err).ToNot(HaveOccurred()) Expect(frame.IsApplicationError).To(BeFalse()) Expect(frame.ErrorCode).To(Equal(qerr.ErrorCode(0x19))) + Expect(frame.FrameType).To(Equal(uint64(0x1337))) Expect(frame.ReasonPhrase).To(Equal(reason)) Expect(b.Len()).To(BeZero()) }) @@ -87,12 +88,13 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() { b := &bytes.Buffer{} frame := &ConnectionCloseFrame{ ErrorCode: 0xbeef, + FrameType: 0x12345, } Expect(frame.Write(b, versionIETFFrames)).To(Succeed()) expected := []byte{0x1c} expected = append(expected, encodeVarInt(0xbeef)...) - expected = append(expected, encodeVarInt(0)...) // frame type - expected = append(expected, encodeVarInt(0)...) // reason phrase length + expected = append(expected, encodeVarInt(0x12345)...) // frame type + expected = append(expected, encodeVarInt(0)...) // reason phrase length Expect(b.Bytes()).To(Equal(expected)) })