forked from quic-go/quic-go
fix length calculcation for CONNECTION_CLOSE frames
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user