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

◆ SendAsync()

async Task< HttpResponseMessage > System.Net.Http.Http3RequestStream.SendAsync ( CancellationToken cancellationToken)
inline

Definition at line 252 of file Http3RequestStream.cs.

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 {
279 HttpContent? content2 = _request.Content;
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 {
297 sendContentObserved = true;
298 }
299 catch
300 {
302 throw;
303 }
304 }
305 else
306 {
308 }
311 HttpConnectionResponseContent responseContent = (HttpConnectionResponseContent)_response.Content;
312 bool useEmptyResponseContent = responseContent.Headers.ContentLength == 0 && sendContentObserved;
314 {
316 responseContent.SetStream(EmptyReadStream.Instance);
317 }
318 else
319 {
320 responseContent.SetStream(new Http3ReadStream(this));
321 }
323 {
324 CookieHelper.ProcessReceivedCookies(_response, _connection.Pool.Settings._cookieContainer);
325 }
326 HttpResponseMessage response = _response;
327 _response = null;
329 result = response;
330 }
331 catch (QuicStreamAbortedException ex) when (ex.ErrorCode == 272)
332 {
333 throw new HttpRequestException(System.SR.net_http_retry_on_older_version, ex, RequestRetryType.RetryOnLowerHttpVersion);
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 {
342 throw new HttpRequestException(System.SR.net_http_client_execution_error, abortException ?? ex3);
343 }
345 {
347 throw new HttpRequestException(System.SR.net_http_client_execution_error, inner);
348 }
349 catch (OperationCanceledException ex4) when (ex4.CancellationToken == requestCancellationSource.Token)
350 {
351 if (cancellationToken.IsCancellationRequested)
352 {
353 _stream.AbortWrite(268L);
354 throw new OperationCanceledException(ex4.Message, ex4, cancellationToken);
355 }
356 throw new HttpRequestException(System.SR.net_http_request_aborted, ex4, RequestRetryType.RetryOnConnectionFailure);
357 }
358 catch (Http3ConnectionException ex5)
359 {
361 throw new HttpRequestException(System.SR.net_http_client_execution_error, ex5);
362 }
363 catch (Exception ex6)
364 {
365 _stream.AbortWrite(258L);
366 if (ex6 is HttpRequestException)
367 {
368 throw;
369 }
370 throw new HttpRequestException(System.SR.net_http_client_execution_error, ex6);
371 }
372 }
373 finally
374 {
375 if (disposeSelf)
376 {
378 }
379 }
380 return result;
381 }
Exception Abort(Exception abortException)
async ValueTask DrainContentLength0Frames(CancellationToken cancellationToken)
async Task ReadResponseAsync(CancellationToken cancellationToken)
async ValueTask FlushSendBufferAsync(bool endStream, CancellationToken cancellationToken)
void BufferHeaders(HttpRequestMessage request)
readonly HttpRequestMessage _request
TaskCompletionSource< bool > _expect100ContinueCompletionSource
CancellationTokenSource _goawayCancellationSource
async Task SendContentAsync(HttpContent content, CancellationToken cancellationToken)
void AbortWrite(long errorCode)
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_request_aborted
Definition SR.cs:120
Definition SR.cs:7
static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token1, CancellationToken token2)
static int Exchange(ref int location1, int value)
static Task CompletedTask
Definition Task.cs:1120
static Task< Task > WhenAny(params Task[] tasks)
Definition Task.cs:3642

References System.Net.Http.Http3RequestStream._connection, System.Net.Http.HttpConnectionSettings._cookieContainer, System.Net.Http.Http3RequestStream._expect100ContinueCompletionSource, System.Net.Http.Http3RequestStream._goawayCancellationSource, System.Net.Http.Http3RequestStream._goawayCancellationToken, System.Net.Http.Http3RequestStream._request, System.Net.Http.Http3RequestStream._response, System.Net.Http.Http3RequestStream._stream, System.Net.Http.HttpConnectionSettings._useCookies, System.Net.Http.Http3Connection.Abort(), System.Net.Http.Http3Connection.AbortException, System.Net.Quic.QuicStream.AbortWrite(), System.Net.Http.HttpContent.AllowDuplex, System.Net.Http.Http3RequestStream.BufferHeaders(), System.cancellationToken, System.Threading.Tasks.Task< TResult >.CompletedTask, System.Net.Http.HttpRequestMessage.Content, System.Net.Http.HttpResponseMessage.Content, System.Threading.CancellationTokenSource.CreateLinkedTokenSource(), System.Net.Http.Http3RequestStream.DisposeAsync(), System.Net.Http.Http3RequestStream.DrainContentLength0Frames(), System.Threading.Interlocked.Exchange(), System.Net.Http.Headers.HttpRequestHeaders.ExpectContinue, System.Net.Http.Http3RequestStream.FlushSendBufferAsync(), System.Net.Http.HttpRequestMessage.HasHeaders, System.Net.Http.HttpRequestMessage.Headers, System.Net.Http.EmptyReadStream.Instance, System.L, System.Net.Http.HttpConnectionBase.LogExceptions(), System.SR.net_http_client_execution_error, System.SR.net_http_request_aborted, System.SR.net_http_retry_on_older_version, System.Net.Http.Http3Connection.Pool, System.Net.Http.CookieHelper.ProcessReceivedCookies(), System.Net.Http.Http3RequestStream.ReadResponseAsync(), System.Net.Http.Http3RequestStream.SendContentAsync(), System.Net.Http.HttpConnectionPool.Settings, and System.Threading.Tasks.Task< TResult >.WhenAny().