You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
887 B
32 lines
887 B
namespace BestHTTP.Extensions |
|
{ |
|
public sealed class PeekableIncomingSegmentStream : BufferSegmentStream |
|
{ |
|
private int peek_listIdx; |
|
private int peek_pos; |
|
|
|
public void BeginPeek() |
|
{ |
|
peek_listIdx = 0; |
|
peek_pos = base.bufferList.Count > 0 ? base.bufferList[0].Offset : 0; |
|
} |
|
|
|
public int PeekByte() |
|
{ |
|
if (base.bufferList.Count == 0) |
|
return -1; |
|
|
|
var segment = base.bufferList[this.peek_listIdx]; |
|
if (peek_pos >= segment.Offset + segment.Count) |
|
{ |
|
if (base.bufferList.Count <= this.peek_listIdx + 1) |
|
return -1; |
|
|
|
segment = base.bufferList[++this.peek_listIdx]; |
|
this.peek_pos = segment.Offset; |
|
} |
|
|
|
return segment.Data[this.peek_pos++]; |
|
} |
|
} |
|
}
|
|
|