forked from quic-go/quic-go
correctly determine the length of STREAM frames for IETF QUIC
The length of the data has an influence on the length of the frame (if it contains the data length), and the length can either consume 1 or 2 bytes due to variable length encoding.
This commit is contained in:
@@ -191,6 +191,14 @@ func (f *StreamFrame) minLengthLegacy(_ protocol.VersionNumber) protocol.ByteCou
|
||||
return length
|
||||
}
|
||||
|
||||
func (f *StreamFrame) maxDataLenLegacy(maxFrameSize protocol.ByteCount, version protocol.VersionNumber) protocol.ByteCount {
|
||||
headerLen := f.minLengthLegacy(version)
|
||||
if headerLen > maxFrameSize {
|
||||
return 0
|
||||
}
|
||||
return maxFrameSize - headerLen
|
||||
}
|
||||
|
||||
// DataLen gives the length of data in bytes
|
||||
func (f *StreamFrame) DataLen() protocol.ByteCount {
|
||||
return protocol.ByteCount(len(f.Data))
|
||||
|
||||
Reference in New Issue
Block a user