EventQueue rewrite. Real world doesn't match wiki docu in the slightest... sorry about that!

This commit is contained in:
cinder
2023-02-04 20:37:46 -06:00
parent 27789b8ed4
commit 3b78c40218
2 changed files with 121 additions and 96 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Sjofn, LLC.
* Copyright (c) 2022-2023, Sjofn, LLC.
* All rights reserved.
*
* - Redistribution and use in source and binary forms, with or without
@@ -234,19 +234,26 @@ namespace LibreMetaverse
private async Task SendRequestAsync(HttpRequestMessage request, CancellationToken? cancellationToken,
DownloadCompleteHandler completeHandler, DownloadProgressHandler progressHandler, ConnectedHandler connectedHandler)
{
using (var response = (cancellationToken.HasValue)
? await SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken.Value)
: await SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
try
{
if (!response.IsSuccessStatusCode)
using (var response = (cancellationToken.HasValue)
? await SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken.Value)
: await SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
{
completeHandler?.Invoke(response, null,
new HttpRequestException(response.StatusCode + " " + response.ReasonPhrase));
if (!response.IsSuccessStatusCode)
{
completeHandler?.Invoke(response, null,
new HttpRequestException(response.StatusCode + " " + response.ReasonPhrase));
}
connectedHandler?.Invoke(response);
await ProcessResponseAsync(response, cancellationToken, completeHandler, progressHandler);
}
connectedHandler?.Invoke(response);
await ProcessResponseAsync(response, cancellationToken, completeHandler, progressHandler);
}
catch (HttpRequestException ex)
{
completeHandler?.Invoke(null, null, ex);
}
}