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

◆ SendHeadersAsync()

async ValueTask< Http2Stream > System.Net.Http.Http2Connection.SendHeadersAsync ( HttpRequestMessage request,
CancellationToken cancellationToken,
bool mustFlush )
inlineprivate

Definition at line 2877 of file Http2Connection.cs.

2878 {
2880 try
2881 {
2882 if (HttpTelemetry.Log.IsEnabled())
2883 {
2884 HttpTelemetry.Log.RequestHeadersStart();
2885 }
2888 ReadOnlyMemory<byte> item = headerBuffer.ActiveMemory;
2889 int num = (item.Length - 1) / 16384 + 1;
2890 int writeBytes = item.Length + num * 9;
2891 Http2Stream http2Stream = new Http2Stream(request, this);
2893 {
2894 if (System.Net.NetEventSource.Log.IsEnabled())
2895 {
2896 s.thisRef.Trace(s.http2Stream.StreamId, $"Started writing. Total header bytes={s.headerBytes.Length}", "SendHeadersAsync");
2897 }
2898 s.thisRef.AddStream(s.http2Stream);
2899 Span<byte> destination = writeBuffer.Span;
2903 FrameFlags frameFlags = ((item3.Length == 0) ? FrameFlags.EndHeaders : FrameFlags.None);
2904 frameFlags |= (s.endStream ? FrameFlags.EndStream : FrameFlags.None);
2905 FrameHeader.WriteTo(destination, item2.Length, FrameType.Headers, frameFlags, s.http2Stream.StreamId);
2906 destination = destination.Slice(9);
2907 item2.Span.CopyTo(destination);
2908 destination = destination.Slice(item2.Length);
2909 if (System.Net.NetEventSource.Log.IsEnabled())
2910 {
2911 s.thisRef.Trace(s.http2Stream.StreamId, $"Wrote HEADERS frame. Length={item2.Length}, flags={frameFlags}", "SendHeadersAsync");
2912 }
2913 while (item3.Length > 0)
2914 {
2916 item2 = tuple2.first;
2917 item3 = tuple2.rest;
2918 frameFlags = ((item3.Length == 0) ? FrameFlags.EndHeaders : FrameFlags.None);
2919 FrameHeader.WriteTo(destination, item2.Length, FrameType.Continuation, frameFlags, s.http2Stream.StreamId);
2920 destination = destination.Slice(9);
2921 item2.Span.CopyTo(destination);
2922 destination = destination.Slice(item2.Length);
2923 if (System.Net.NetEventSource.Log.IsEnabled())
2924 {
2925 s.thisRef.Trace(s.http2Stream.StreamId, $"Wrote CONTINUATION frame. Length={item2.Length}, flags={frameFlags}", "SendHeadersAsync");
2926 }
2927 }
2928 return s.mustFlush || s.endStream;
2930 if (HttpTelemetry.Log.IsEnabled())
2931 {
2932 HttpTelemetry.Log.RequestHeadersStop();
2933 }
2934 return http2Stream;
2935 }
2936 catch
2937 {
2938 ReleaseStream();
2939 throw;
2940 }
2941 finally
2942 {
2943 headerBuffer.Dispose();
2944 }
2945 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static ReadOnlyMemory< byte > ReadOnlyMemory< byte > rest SplitBuffer(ReadOnlyMemory< byte > buffer, int maxSize)
void WriteHeaders(HttpRequestMessage request, ref System.Net.ArrayBuffer headerBuffer)
static ReadOnlyMemory< byte > first
Http2Connection(HttpConnectionPool pool, Stream stream)
static readonly System.Net.NetEventSource Log

References System.cancellationToken, System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), System.destination, System.Net.Http.Http2Connection.first, System.item, System.Net.Http.HttpTelemetry.Log, System.Net.NetEventSource.Log, System.Net.Http.Http2Connection.ReleaseStream(), System.s, System.Net.Http.Http2Connection.SplitBuffer(), System.Net.Http.Http2Connection.WriteHeaders(), and System.Net.Http.Http2Connection.FrameHeader.WriteTo().

Referenced by System.Net.Http.Http2Connection.SendAsync().