Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Http3RequestStream.cs
Go to the documentation of this file.
2using System.IO;
9using System.Text;
12
13namespace System.Net.Http;
14
15[SupportedOSPlatform("windows")]
16[SupportedOSPlatform("linux")]
17[SupportedOSPlatform("macos")]
19{
20 private sealed class Http3ReadStream : HttpBaseStream
21 {
23
25
26 public override bool CanRead => _stream != null;
27
28 public override bool CanWrite => false;
29
31 {
33 _response = stream._response;
34 }
35
37 {
38 Dispose(disposing: false);
39 }
40
41 protected override void Dispose(bool disposing)
42 {
44 if (http3RequestStream != null)
45 {
46 if (disposing)
47 {
48 http3RequestStream.Dispose();
49 }
50 else
51 {
52 http3RequestStream._connection.RemoveStream(http3RequestStream._stream);
53 http3RequestStream._connection = null;
54 }
55 _response = null;
56 base.Dispose(disposing);
57 }
58 }
59
60 public override async ValueTask DisposeAsync()
61 {
63 if (http3RequestStream != null)
64 {
65 await http3RequestStream.DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
66 _response = null;
67 await base.DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
68 }
69 }
70
71 public override int Read(Span<byte> buffer)
72 {
73 if (_stream == null)
74 {
75 throw new ObjectDisposedException("Http3RequestStream");
76 }
78 }
79
88
93 }
94
95 private sealed class Http3WriteStream : HttpBaseStream
96 {
98
99 public override bool CanRead => false;
100
101 public override bool CanWrite => _stream != null;
102
107
108 protected override void Dispose(bool disposing)
109 {
110 _stream = null;
111 base.Dispose(disposing);
112 }
113
114 public override int Read(Span<byte> buffer)
115 {
116 throw new NotSupportedException();
117 }
118
123
132
134 {
135 if (_stream == null)
136 {
137 return Task.FromException(new ObjectDisposedException("Http3WriteStream"));
138 }
140 }
141 }
142
150
151 private readonly HttpRequestMessage _request;
152
154
155 private long _streamId = -1L;
156
158
160
162
164
166
167 private bool _disposed;
168
170
172
174
176
178
180
181 private string[] _headerValues = Array.Empty<string>();
182
184
186
188
190
191 public long StreamId
192 {
193 get
194 {
195 return Volatile.Read(ref _streamId);
196 }
197 set
198 {
200 }
201 }
202
215
216 public void Dispose()
217 {
218 if (!_disposed)
219 {
220 _disposed = true;
221 AbortStream();
224 }
225 }
226
228 {
229 if (!_disposed)
230 {
231 _disposed = true;
232 AbortStream();
233 await _stream.DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
235 }
236 }
237
238 private void DisposeSyncHelper()
239 {
241 _sendBuffer.Dispose();
242 _recvBuffer.Dispose();
244 }
245
251
253 {
254 bool disposeSelf = true;
256 HttpResponseMessage result;
257 try
258 {
259 _ = 4;
260 try
261 {
264 {
266 }
268 {
270 }
271 HttpContent? content = _request.Content;
272 CancellationToken cancellationToken2 = ((content != null && !content.AllowDuplex) ? requestCancellationSource.Token : default(CancellationToken));
275 bool sendContentObserved = false;
276 int num;
277 if (!sendContentTask.IsCompleted)
278 {
280 num = ((content2 == null || !content2.AllowDuplex) ? 1 : 0);
281 }
282 else
283 {
284 num = 1;
285 }
286 bool flag = (byte)num != 0;
287 bool flag2 = flag;
288 if (!flag2)
289 {
291 }
292 if (flag2 || sendContentTask.IsCompleted)
293 {
294 try
295 {
296 await sendContentTask.ConfigureAwait(continueOnCapturedContext: false);
297 sendContentObserved = true;
298 }
299 catch
300 {
302 throw;
303 }
304 }
305 else
306 {
308 }
309 await readResponseTask.ConfigureAwait(continueOnCapturedContext: false);
312 bool useEmptyResponseContent = responseContent.Headers.ContentLength == 0 && sendContentObserved;
314 {
317 }
318 else
319 {
320 responseContent.SetStream(new Http3ReadStream(this));
321 }
323 {
325 }
327 _response = null;
329 result = response;
330 }
331 catch (QuicStreamAbortedException ex) when (ex.ErrorCode == 272)
332 {
334 }
335 catch (QuicStreamAbortedException ex2) when (ex2.ErrorCode == 267)
336 {
337 throw new HttpRequestException(System.SR.net_http_request_aborted, ex2, RequestRetryType.RetryOnConnectionFailure);
338 }
340 {
343 }
345 {
348 }
349 catch (OperationCanceledException ex4) when (ex4.CancellationToken == requestCancellationSource.Token)
350 {
351 if (cancellationToken.IsCancellationRequested)
352 {
353 _stream.AbortWrite(268L);
355 }
356 throw new HttpRequestException(System.SR.net_http_request_aborted, ex4, RequestRetryType.RetryOnConnectionFailure);
357 }
359 {
362 }
363 catch (Exception ex6)
364 {
365 _stream.AbortWrite(258L);
367 {
368 throw;
369 }
371 }
372 }
373 finally
374 {
375 if (disposeSelf)
376 {
377 await DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
378 }
379 }
380 return result;
381 }
382
384 {
385 do
386 {
387 _headerState = HeaderState.StatusHeader;
389 if (http3FrameType != Http3FrameType.Headers)
390 {
391 if (System.Net.NetEventSource.Log.IsEnabled())
392 {
393 Trace($"Expected HEADERS as first response frame; received {http3FrameType}.", "ReadResponseAsync");
394 }
396 }
398 }
400 _headerState = HeaderState.TrailingHeaders;
401 }
402
404 {
406 {
407 Timer timer = null;
408 try
409 {
411 {
412 timer = new Timer(delegate(object o)
413 {
414 ((Http3RequestStream)o)._expect100ContinueCompletionSource.TrySetResult(result: true);
416 }
418 {
419 return;
420 }
421 }
422 finally
423 {
424 if (timer != null)
425 {
426 await timer.DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
427 }
428 }
429 }
430 _requestContentLengthRemaining = content.Headers.ContentLength ?? (-1);
432 {
434 }
436 if (_sendBuffer.ActiveLength != 0)
437 {
439 }
440 else
441 {
443 }
444 }
445
447 {
448 if (buffer.Length == 0)
449 {
450 return;
451 }
454 {
456 {
457 string net_http_content_write_larger_than_content_length = System.SR.net_http_content_write_larger_than_content_length;
458 throw new IOException(net_http_content_write_larger_than_content_length, new HttpRequestException(net_http_content_write_larger_than_content_length));
459 }
462 {
464 _gatheredSendBuffer[0] = _sendBuffer.ActiveMemory;
467 _sendBuffer.Discard(_sendBuffer.ActiveLength);
469 }
470 else
471 {
473 }
474 }
475 else
476 {
478 _gatheredSendBuffer[0] = _sendBuffer.ActiveMemory;
481 _sendBuffer.Discard(_sendBuffer.ActiveLength);
482 }
483 }
484
491
493 {
494 while (true)
495 {
497 if (http3FrameType.HasValue)
498 {
499 Http3FrameType valueOrDefault = http3FrameType.GetValueOrDefault();
500 if (valueOrDefault == Http3FrameType.Data)
501 {
502 if (num != 0L)
503 {
504 if (System.Net.NetEventSource.Log.IsEnabled())
505 {
506 Trace("Response content exceeded Content-Length.", "DrainContentLength0Frames");
507 }
509 }
510 continue;
511 }
512 if (valueOrDefault != Http3FrameType.Headers)
513 {
514 break;
515 }
518 }
520 break;
521 }
522 }
523
525 {
527 if (trailingHeaders == null || trailingHeaders.Count <= 0)
528 {
529 return;
530 }
531 foreach (var (descriptor, value) in _trailingHeaders)
532 {
533 responseMessage.TrailingHeaders.TryAddWithoutValidation(descriptor, value);
534 }
536 }
537
539 {
540 _sendBuffer.Commit(9);
541 _sendBuffer.EnsureAvailableSpace(2);
542 _sendBuffer.AvailableSpan[0] = 0;
543 _sendBuffer.AvailableSpan[1] = 0;
544 _sendBuffer.Commit(2);
546 BufferBytes(httpMethod.Http3EncodedBytes);
548 if (request.HasHeaders && request.Headers.Host != null)
549 {
551 }
552 else
553 {
555 }
556 string pathAndQuery = request.RequestUri.PathAndQuery;
557 if (pathAndQuery == "/")
558 {
560 }
561 else
562 {
564 }
566 if (request.HasHeaders)
567 {
568 if (request.HasHeaders && request.Headers.TransferEncodingChunked == true)
569 {
570 request.Headers.TransferEncodingChunked = false;
571 }
573 }
575 {
577 if (cookieHeader != string.Empty)
578 {
581 }
582 }
583 if (request.Content == null)
584 {
585 if (httpMethod.MustHaveRequestBody)
586 {
588 }
589 }
590 else
591 {
592 BufferHeaderCollection(request.Content.Headers);
593 }
594 int num = _sendBuffer.ActiveLength - 9;
596 _sendBuffer.Discard(9 - byteCount - 1);
597 _sendBuffer.ActiveSpan[0] = 1;
598 int num2 = VariableLengthIntegerHelper.WriteInteger(_sendBuffer.ActiveSpan.Slice(1, byteCount), num);
599 }
600
602 {
603 if (headers.HeaderStore == null)
604 {
605 return;
606 }
609 {
613 KnownHeader knownHeader = item.Key.KnownHeader;
614 if (knownHeader != null)
615 {
617 {
618 continue;
619 }
620 if (item.Key.KnownHeader == KnownHeaders.TE)
621 {
623 for (int i = 0; i < readOnlySpan2.Length; i++)
624 {
625 string text = readOnlySpan2[i];
626 if (string.Equals(text, "trailers", StringComparison.OrdinalIgnoreCase))
627 {
629 break;
630 }
631 }
632 }
633 else
634 {
635 BufferBytes(knownHeader.Http3EncodedName);
636 string separator = null;
637 if (readOnlySpan.Length > 1)
638 {
639 HttpHeaderParser parser = item.Key.Parser;
640 separator = ((parser == null || !parser.SupportsMultipleValues) ? ", " : parser.Separator);
641 }
643 }
644 }
645 else
646 {
648 }
649 }
650 }
651
652 private void BufferIndexedHeader(int index)
653 {
654 int bytesWritten;
656 {
657 _sendBuffer.Grow();
658 }
660 }
661
671
681
683 {
684 int bytesWritten;
686 {
687 _sendBuffer.Grow();
688 }
690 }
691
693 {
694 int length;
696 {
697 _sendBuffer.Grow();
698 }
699 _sendBuffer.Commit(length);
700 }
701
703 {
704 int bytesWritten;
706 {
707 _sendBuffer.Grow();
708 }
710 }
711
713 {
714 _sendBuffer.EnsureAvailableSpace(span.Length);
715 span.CopyTo(_sendBuffer.AvailableSpan);
716 _sendBuffer.Commit(span.Length);
717 }
718
720 {
721 while (true)
722 {
724 {
725 _recvBuffer.EnsureAvailableSpace(16);
727 if (bytesRead == 0)
728 {
729 break;
730 }
731 _recvBuffer.Commit(bytesRead);
732 continue;
733 }
734 _recvBuffer.Discard(bytesRead);
735 if (System.Net.NetEventSource.Log.IsEnabled())
736 {
737 Trace($"Received frame {a} of length {b}.", "ReadFrameEnvelopeAsync");
738 }
740 if ((ulong)http3FrameType <= 13uL)
741 {
742 switch (http3FrameType)
743 {
744 case Http3FrameType.Data:
745 case Http3FrameType.Headers:
746 return ((Http3FrameType)a, b);
747 case Http3FrameType.ReservedHttp2Priority:
748 case Http3FrameType.Settings:
749 case Http3FrameType.ReservedHttp2Ping:
750 case Http3FrameType.GoAway:
751 case Http3FrameType.ReservedHttp2WindowUpdate:
752 case Http3FrameType.ReservedHttp2Continuation:
753 case Http3FrameType.MaxPushId:
754 throw new Http3ConnectionException(Http3ErrorCode.UnexpectedFrame);
755 case Http3FrameType.CancelPush:
756 case Http3FrameType.PushPromise:
757 throw new Http3ConnectionException(Http3ErrorCode.IdError);
758 }
759 }
761 }
762 if (_recvBuffer.ActiveLength == 0)
763 {
764 return (null, 0L);
765 }
767 }
768
770 {
772 {
773 _stream.AbortWrite(263L);
775 }
777 while (headersLength != 0L)
778 {
779 if (_recvBuffer.ActiveLength == 0)
780 {
781 _recvBuffer.EnsureAvailableSpace(1);
782 int num = await _stream.ReadAsync(_recvBuffer.AvailableMemory, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
783 if (num == 0)
784 {
785 if (System.Net.NetEventSource.Log.IsEnabled())
786 {
787 Trace($"Server closed response stream before entire header payload could be read. {headersLength:N0} bytes remaining.", "ReadHeadersAsync");
788 }
790 }
791 _recvBuffer.Commit(num);
792 }
793 int num2 = (int)Math.Min(headersLength, _recvBuffer.ActiveLength);
794 _headerDecoder.Decode(_recvBuffer.ActiveSpan.Slice(0, num2), this);
795 _recvBuffer.Discard(num2);
797 }
799 }
800
802 {
803 if (!HeaderDescriptor.TryGet(name, out var descriptor))
804 {
806 }
807 OnHeader(null, descriptor, null, value);
808 }
809
815
821
822 private void GetStaticQPackHeader(int index, out HeaderDescriptor descriptor, out string knownValue)
823 {
825 {
826 if (System.Net.NetEventSource.Log.IsEnabled())
827 {
828 Trace($"Response contains invalid static header index '{index}'.", "GetStaticQPackHeader");
829 }
830 throw new Http3ConnectionException(Http3ErrorCode.ProtocolError);
831 }
832 }
833
835 {
836 if (descriptor.Name[0] == ':')
837 {
838 if (descriptor.KnownHeader != KnownHeaders.PseudoStatus)
839 {
840 if (System.Net.NetEventSource.Log.IsEnabled())
841 {
842 Trace("Received unknown pseudo-header '" + descriptor.Name + "'.", "OnHeader");
843 }
844 throw new Http3ConnectionException(Http3ErrorCode.ProtocolError);
845 }
846 if (_headerState != 0)
847 {
848 if (System.Net.NetEventSource.Log.IsEnabled())
849 {
850 Trace("Received extra status header.", "OnHeader");
851 }
852 throw new Http3ConnectionException(Http3ErrorCode.ProtocolError);
853 }
855 {
856 24 => 103,
857 25 => 200,
858 26 => 304,
859 27 => 404,
860 28 => 503,
861 63 => 100,
862 64 => 204,
863 65 => 206,
864 66 => 302,
865 67 => 400,
866 68 => 403,
867 69 => 421,
868 70 => 425,
869 71 => 500,
870 _ => ParseStatusCode(staticIndex, staticValue),
871 }));
873 {
875 RequestMessage = _request,
876 Content = new HttpConnectionResponseContent(),
877 StatusCode = (HttpStatusCode)num
878 };
879 if (num < 200)
880 {
881 _headerState = HeaderState.SkipExpect100Headers;
883 {
885 }
886 return;
887 }
888 _headerState = HeaderState.ResponseHeaders;
890 {
891 bool result = num < 300;
892 if (System.Net.NetEventSource.Log.IsEnabled())
893 {
894 Trace($"Expecting 100 Continue but received final status {num}.", "OnHeader");
895 }
897 }
898 }
899 else
900 {
901 if (_headerState == HeaderState.SkipExpect100Headers)
902 {
903 return;
904 }
905 string text = staticValue;
906 if (text == null)
907 {
910 }
911 switch (_headerState)
912 {
913 case HeaderState.StatusHeader:
914 if (System.Net.NetEventSource.Log.IsEnabled())
915 {
916 Trace("Received headers without :status.", "OnHeader");
917 }
918 throw new Http3ConnectionException(Http3ErrorCode.ProtocolError);
919 case HeaderState.ResponseHeaders:
920 if (descriptor.HeaderType.HasFlag(HttpHeaderType.Content))
921 {
923 }
924 else
925 {
926 _response.Headers.TryAddWithoutValidation(descriptor.HeaderType.HasFlag(HttpHeaderType.Request) ? descriptor.AsCustomHeader() : descriptor, text);
927 }
928 break;
929 case HeaderState.TrailingHeaders:
930 _trailingHeaders.Add((descriptor.HeaderType.HasFlag(HttpHeaderType.Request) ? descriptor.AsCustomHeader() : descriptor, text));
931 break;
932 case HeaderState.SkipExpect100Headers:
933 break;
934 }
935 }
936 int ParseStatusCode(int? index, string value)
937 {
938 string message = $"Unexpected QPACK table reference for Status code: index={index} value='{value}'";
939 if (System.Net.NetEventSource.Log.IsEnabled())
940 {
941 Trace(message, "OnHeader");
942 }
944 }
945 }
946
948 {
949 while (payloadLength != 0L)
950 {
951 if (_recvBuffer.ActiveLength == 0)
952 {
953 _recvBuffer.EnsureAvailableSpace(1);
954 int num = await _stream.ReadAsync(_recvBuffer.AvailableMemory, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
955 if (num == 0)
956 {
957 throw new Http3ConnectionException(Http3ErrorCode.FrameError);
958 }
959 _recvBuffer.Commit(num);
960 }
961 long num2 = Math.Min(payloadLength, _recvBuffer.ActiveLength);
962 _recvBuffer.Discard((int)num2);
964 }
965 }
966
968 {
969 try
970 {
971 int num = 0;
972 while (buffer.Length != 0 && (_responseDataPayloadRemaining > 0 || ReadNextDataFrameAsync(response, CancellationToken.None).AsTask().GetAwaiter().GetResult()))
973 {
974 if (_recvBuffer.ActiveLength != 0)
975 {
976 int num2 = (int)Math.Min(buffer.Length, Math.Min(_responseDataPayloadRemaining, _recvBuffer.ActiveLength));
977 Span<byte> span = _recvBuffer.ActiveSpan;
978 span = span.Slice(0, num2);
980 num += num2;
982 _recvBuffer.Discard(num2);
983 buffer = buffer.Slice(num2);
984 if (_responseDataPayloadRemaining == 0L && _recvBuffer.ActiveLength == 0)
985 {
986 break;
987 }
988 continue;
989 }
991 int num3 = _stream.Read(buffer.Slice(0, length));
992 if (num3 == 0)
993 {
995 }
996 num += num3;
998 buffer = buffer.Slice(num3);
999 break;
1000 }
1001 return num;
1002 }
1003 catch (Exception ex)
1004 {
1006 return 0;
1007 }
1008 }
1009
1011 {
1012 _ = 1;
1013 try
1014 {
1015 int totalBytesRead = 0;
1016 while (buffer.Length != 0)
1017 {
1018 bool flag = _responseDataPayloadRemaining <= 0;
1019 bool flag2 = flag;
1020 if (flag2)
1021 {
1023 }
1024 if (flag2)
1025 {
1026 break;
1027 }
1028 if (_recvBuffer.ActiveLength != 0)
1029 {
1030 int num = (int)Math.Min(buffer.Length, Math.Min(_responseDataPayloadRemaining, _recvBuffer.ActiveLength));
1031 Span<byte> span = _recvBuffer.ActiveSpan;
1032 span = span.Slice(0, num);
1033 span.CopyTo(buffer.Span);
1034 totalBytesRead += num;
1036 _recvBuffer.Discard(num);
1037 buffer = buffer.Slice(num);
1038 if (_responseDataPayloadRemaining == 0L && _recvBuffer.ActiveLength == 0)
1039 {
1040 break;
1041 }
1042 continue;
1043 }
1045 int num2 = await _stream.ReadAsync(buffer.Slice(0, length), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
1046 if (num2 == 0)
1047 {
1049 }
1052 buffer = buffer.Slice(num2);
1053 break;
1054 }
1055 return totalBytesRead;
1056 }
1057 catch (Exception ex)
1058 {
1060 return 0;
1061 }
1062 }
1063
1089
1091 {
1093 {
1094 return false;
1095 }
1096 while (true)
1097 {
1099 switch (http3FrameType)
1100 {
1101 default:
1102 continue;
1103 case Http3FrameType.Data:
1104 goto IL_00d6;
1105 case Http3FrameType.Headers:
1108 break;
1109 case null:
1110 break;
1111 }
1112 break;
1113 IL_00d6:
1114 if (num != 0L)
1115 {
1117 return true;
1118 }
1119 }
1122 return false;
1123 }
1124
1125 public void Trace(string message, [CallerMemberName] string memberName = null)
1126 {
1128 }
1129
1130 private void AbortStream()
1131 {
1133 {
1134 _stream.AbortWrite(268L);
1135 }
1137 {
1138 _stream.AbortRead(268L);
1139 }
1140 }
1141}
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
virtual ValueTask DisposeAsync()
Definition Stream.cs:654
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static readonly Version Version30
static void ProcessReceivedCookies(HttpResponseMessage response, CookieContainer cookieContainer)
static EmptyReadStream Instance
bool TryAddWithoutValidation(string name, string? value)
static int GetStoreValuesIntoStringArray(HeaderDescriptor descriptor, object sourceValues, [NotNull] ref string[] values)
static readonly KnownHeader Host
static readonly KnownHeader Connection
static readonly KnownHeader TE
static readonly KnownHeader ProxyConnection
static readonly KnownHeader PseudoStatus
static readonly KnownHeader Upgrade
override void Trace(string message, [CallerMemberName] string memberName=null)
void RemoveStream(QuicStream stream)
Exception Abort(Exception abortException)
static bool TryWriteFrameEnvelope(Http3FrameType frameType, long payloadLength, Span< byte > buffer, out int bytesWritten)
Definition Http3Frame.cs:21
static bool TryReadIntegerPair(ReadOnlySpan< byte > buffer, out long a, out long b, out int bytesRead)
Definition Http3Frame.cs:5
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken)
override Task FlushAsync(CancellationToken cancellationToken)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken)
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken)
void BufferHeaderCollection(HttpHeaders headers)
void CopyTrailersToResponseMessage(HttpResponseMessage responseMessage)
async ValueTask DrainContentLength0Frames(CancellationToken cancellationToken)
void BufferLiteralHeaderWithoutNameReference(string name, ReadOnlySpan< string > values, string separator, Encoding valueEncoding)
async Task ReadResponseAsync(CancellationToken cancellationToken)
async ValueTask< bool > ReadNextDataFrameAsync(HttpResponseMessage response, CancellationToken cancellationToken)
async ValueTask ReadHeadersAsync(long headersLength, CancellationToken cancellationToken)
Http3RequestStream(HttpRequestMessage request, Http3Connection connection, QuicStream stream)
async ValueTask WriteRequestContentAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken)
int ReadResponseContent(HttpResponseMessage response, Span< byte > buffer)
void IHttpHeadersHandler. OnHeader(ReadOnlySpan< byte > name, ReadOnlySpan< byte > value)
async ValueTask< int > ReadResponseContentAsync(HttpResponseMessage response, Memory< byte > buffer, CancellationToken cancellationToken)
void BufferFrameEnvelope(Http3FrameType frameType, long payloadLength)
void BufferBytes(ReadOnlySpan< byte > span)
void Trace(string message, [CallerMemberName] string memberName=null)
async ValueTask<(Http3FrameType? frameType, long payloadLength)> ReadFrameEnvelopeAsync(CancellationToken cancellationToken)
async ValueTask FlushSendBufferAsync(bool endStream, CancellationToken cancellationToken)
void HandleReadResponseContentException(Exception ex, CancellationToken cancellationToken)
void GetStaticQPackHeader(int index, out HeaderDescriptor descriptor, out string knownValue)
void BufferHeaders(HttpRequestMessage request)
void BufferLiteralHeaderValues(ReadOnlySpan< string > values, string separator, Encoding valueEncoding)
readonly ReadOnlyMemory< byte >[] _gatheredSendBuffer
async Task< HttpResponseMessage > SendAsync(CancellationToken cancellationToken)
async ValueTask SkipUnknownPayloadAsync(long payloadLength, CancellationToken cancellationToken)
List<(HeaderDescriptor name, string value)> _trailingHeaders
void OnHeader(int? staticIndex, HeaderDescriptor descriptor, string staticValue, ReadOnlySpan< byte > literalValue)
readonly HttpRequestMessage _request
void BufferLiteralHeaderWithStaticNameReference(int nameIndex, string value, Encoding valueEncoding=null)
TaskCompletionSource< bool > _expect100ContinueCompletionSource
CancellationTokenSource _goawayCancellationSource
void BufferLiteralHeaderWithoutNameReference(string name, string value, Encoding valueEncoding)
async Task SendContentAsync(HttpContent content, CancellationToken cancellationToken)
string GetResponseHeaderValueWithCaching(HeaderDescriptor descriptor, ReadOnlySpan< byte > value, Encoding valueEncoding)
static int ParseStatusCode(ReadOnlySpan< byte > value)
HeaderEncodingSelector< HttpRequestMessage > _responseHeaderEncodingSelector
HeaderEncodingSelector< HttpRequestMessage > _requestHeaderEncodingSelector
Task CopyToAsync(Stream stream)
HttpContentHeaders Headers
static HttpMethod Normalize(HttpMethod method)
void Decode(ReadOnlySpan< byte > headerBlock, IHttpHeadersHandler handler)
static bool EncodeStaticIndexedHeaderField(int index, Span< byte > destination, out int bytesWritten)
static bool EncodeValueString(string s, Encoding valueEncoding, Span< byte > buffer, out int length)
static bool EncodeLiteralHeaderFieldWithStaticNameReference(int index, string value, Span< byte > destination, out int bytesWritten)
static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, string value, Span< byte > destination, out int bytesWritten)
static int WriteInteger(Span< byte > buffer, long longToEncode)
static readonly System.Net.NetEventSource Log
override Task FlushAsync(CancellationToken cancellationToken)
override void Dispose(bool disposing)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
void AbortWrite(long errorCode)
void AbortRead(long errorCode)
override int Read(byte[] buffer, int offset, int count)
static string net_http_invalid_response_premature_eof
Definition SR.cs:94
static string net_http_invalid_response
Definition SR.cs:92
static string net_http_response_headers_exceeded_length
Definition SR.cs:124
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_client_execution_error
Definition SR.cs:58
static string net_http_retry_on_older_version
Definition SR.cs:184
static string net_http_invalid_response_premature_eof_bytecount
Definition SR.cs:98
static string net_http_request_aborted
Definition SR.cs:120
static string net_http_content_write_larger_than_content_length
Definition SR.cs:186
static string net_http_invalid_response_header_name
Definition SR.cs:118
Definition SR.cs:7
static Encoding ASCII
Definition Encoding.cs:511
static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token1, CancellationToken token2)
static int Exchange(ref int location1, int value)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
static Task FromException(Exception exception)
Definition Task.cs:3341
static Task CompletedTask
Definition Task.cs:1120
static Task< Task > WhenAny(params Task[] tasks)
Definition Task.cs:3642
static readonly TimeSpan InfiniteTimeSpan
Definition Timeout.cs:5
static bool Read(ref bool location)
Definition Volatile.cs:67
static void Write(ref bool location, bool value)
Definition Volatile.cs:74
void OnHeader(ReadOnlySpan< byte > name, ReadOnlySpan< byte > value)
static bool TryGetStaticQPackHeader(int index, out HeaderDescriptor descriptor, [NotNullWhen(true)] out string knownValue)
static bool TryGet(string headerName, out HeaderDescriptor descriptor)
static ValueTask FromException(Exception exception)
Definition ValueTask.cs:190