fix length calculcation for CONNECTION_CLOSE frames

This commit is contained in:
Marten Seemann
2019-08-22 12:20:13 +07:00
parent 2133d01956
commit 0dbfefc1f6
2 changed files with 2 additions and 1 deletions

View File

@@ -62,7 +62,7 @@ func parseConnectionCloseFrame(r *bytes.Reader, version protocol.VersionNumber)
func (f *ConnectionCloseFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
length := 1 + utils.VarIntLen(uint64(f.ErrorCode)) + utils.VarIntLen(uint64(len(f.ReasonPhrase))) + protocol.ByteCount(len(f.ReasonPhrase))
if !f.IsApplicationError {
length++ // for the frame type
length += utils.VarIntLen(f.FrameType) // for the frame type
}
return length
}

View File

@@ -132,6 +132,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
b := &bytes.Buffer{}
f := &ConnectionCloseFrame{
ErrorCode: 0xcafe,
FrameType: 0xdeadbeef,
ReasonPhrase: "foobar",
}
Expect(f.Write(b, versionIETFFrames)).To(Succeed())