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:
@@ -145,11 +145,11 @@ func (s *sendStream) popStreamFrame(maxBytes protocol.ByteCount) (*wire.StreamFr
|
||||
Offset: s.writeOffset,
|
||||
DataLenPresent: true,
|
||||
}
|
||||
frameLen := frame.MinLength(s.version)
|
||||
if frameLen >= maxBytes { // a STREAM frame must have at least one byte of data
|
||||
maxDataLen := frame.MaxDataLen(maxBytes, s.version)
|
||||
if maxDataLen == 0 { // a STREAM frame must have at least one byte of data
|
||||
return nil, s.dataForWriting != nil
|
||||
}
|
||||
frame.Data, frame.FinBit = s.getDataForWriting(maxBytes - frameLen)
|
||||
frame.Data, frame.FinBit = s.getDataForWriting(maxDataLen)
|
||||
if len(frame.Data) == 0 && !frame.FinBit {
|
||||
// this can happen if:
|
||||
// - popStreamFrame is called but there's no data for writing
|
||||
|
||||
Reference in New Issue
Block a user