forked from quic-go/quic-go
Merge pull request #2086 from lucas-clemente/fix-conn-close-length
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 {
|
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))
|
length := 1 + utils.VarIntLen(uint64(f.ErrorCode)) + utils.VarIntLen(uint64(len(f.ReasonPhrase))) + protocol.ByteCount(len(f.ReasonPhrase))
|
||||||
if !f.IsApplicationError {
|
if !f.IsApplicationError {
|
||||||
length++ // for the frame type
|
length += utils.VarIntLen(f.FrameType) // for the frame type
|
||||||
}
|
}
|
||||||
return length
|
return length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
|
|||||||
b := &bytes.Buffer{}
|
b := &bytes.Buffer{}
|
||||||
f := &ConnectionCloseFrame{
|
f := &ConnectionCloseFrame{
|
||||||
ErrorCode: 0xcafe,
|
ErrorCode: 0xcafe,
|
||||||
|
FrameType: 0xdeadbeef,
|
||||||
ReasonPhrase: "foobar",
|
ReasonPhrase: "foobar",
|
||||||
}
|
}
|
||||||
Expect(f.Write(b, versionIETFFrames)).To(Succeed())
|
Expect(f.Write(b, versionIETFFrames)).To(Succeed())
|
||||||
|
|||||||
Reference in New Issue
Block a user