move splitting of StreamFrames to StreamFrameQueue

work towards #146
This commit is contained in:
Marten Seemann
2016-05-26 11:14:38 +07:00
parent 93771708ae
commit 758334f6aa
5 changed files with 170 additions and 125 deletions

View File

@@ -199,24 +199,3 @@ func (f *StreamFrame) MinLength() (protocol.ByteCount, error) {
return length + 1, nil
}
// MaybeSplitOffFrame removes the first n bytes and returns them as a separate frame. If n >= len(n), nil is returned and nothing is modified.
func (f *StreamFrame) MaybeSplitOffFrame(n protocol.ByteCount) *StreamFrame {
minLength, _ := f.MinLength() // StreamFrame.MinLength *never* errors
if n >= minLength-1+protocol.ByteCount(len(f.Data)) {
return nil
}
n -= minLength - 1
defer func() {
f.Data = f.Data[n:]
f.Offset += n
}()
return &StreamFrame{
FinBit: false,
StreamID: f.StreamID,
Offset: f.Offset,
Data: f.Data[:n],
}
}