Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadFrameAsync()

async ValueTask< FrameHeader > System.Net.Http.Http2Connection.ReadFrameAsync ( bool initialFrame = false)
inlineprivate

Definition at line 1990 of file Http2Connection.cs.

1991 {
1992 if (System.Net.NetEventSource.Log.IsEnabled())
1993 {
1994 Trace($"{"initialFrame"}={initialFrame}", "ReadFrameAsync");
1995 }
1996 if (_incomingBuffer.ActiveLength < 9)
1997 {
1998 _incomingBuffer.EnsureAvailableSpace(9 - _incomingBuffer.ActiveLength);
1999 do
2000 {
2002 _incomingBuffer.Commit(num);
2003 if (num == 0)
2004 {
2005 if (_incomingBuffer.ActiveLength == 0)
2006 {
2008 }
2009 else
2010 {
2012 }
2013 }
2014 }
2015 while (_incomingBuffer.ActiveLength < 9);
2016 }
2017 FrameHeader frameHeader = FrameHeader.ReadFrom(_incomingBuffer.ActiveSpan);
2018 if (frameHeader.PayloadLength > 16384)
2019 {
2020 if (initialFrame && System.Net.NetEventSource.Log.IsEnabled())
2021 {
2022 string @string = Encoding.ASCII.GetString(_incomingBuffer.ActiveSpan.Slice(0, Math.Min(20, _incomingBuffer.ActiveLength)));
2023 Trace("HTTP/2 handshake failed. Server returned " + @string, "ReadFrameAsync");
2024 }
2025 _incomingBuffer.Discard(9);
2027 }
2028 _incomingBuffer.Discard(9);
2029 if (_incomingBuffer.ActiveLength < frameHeader.PayloadLength)
2030 {
2031 _incomingBuffer.EnsureAvailableSpace(frameHeader.PayloadLength - _incomingBuffer.ActiveLength);
2032 do
2033 {
2035 _incomingBuffer.Commit(num2);
2036 if (num2 == 0)
2037 {
2038 ThrowPrematureEOF(frameHeader.PayloadLength);
2039 }
2040 }
2041 while (_incomingBuffer.ActiveLength < frameHeader.PayloadLength);
2042 }
2043 return frameHeader;
2044 static void ThrowMissingFrame()
2045 {
2047 }
2049 {
2051 }
2052 }
Task< int > ReadAsync(byte[] buffer, int offset, int count)
Definition Stream.cs:762
System.Net.ArrayBuffer _incomingBuffer
override void Trace(string message, [CallerMemberName] string memberName=null)
static readonly System.Net.NetEventSource Log
static string net_http_invalid_response_missing_frame
Definition SR.cs:96
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_invalid_response_premature_eof_bytecount
Definition SR.cs:98
Definition SR.cs:7
static Encoding ASCII
Definition Encoding.cs:511
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226

References System.Net.Http.Http2Connection._incomingBuffer, System.Net.Http.Http2Connection._stream, System.Text.Encoding.ASCII, System.Threading.Tasks.Task< TResult >.ConfigureAwait(), System.SR.Format(), System.Net.NetEventSource.Log, System.Math.Min(), System.SR.net_http_invalid_response_missing_frame, System.SR.net_http_invalid_response_premature_eof_bytecount, System.IO.Stream.ReadAsync(), System.Net.Http.Http2Connection.FrameHeader.ReadFrom(), System.Net.Http.Http2Connection.ThrowProtocolError(), and System.Net.Http.Http2Connection.Trace().

Referenced by System.Net.Http.Http2Connection.ProcessHeadersFrame(), and System.Net.Http.Http2Connection.ProcessIncomingFramesAsync().