Skip to content

Commit afa819c

Browse files
committed
Revert "Fix configure await on Helpers MakeRequest"
This reverts commit 79605e0.
1 parent 9a984fb commit afa819c

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

Storage/Extensions/HttpClientProgress.cs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,39 @@ internal static class HttpClientProgress
2727
}
2828
}
2929

30-
using var response = await client.SendAsync(message, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
31-
if (!response.IsSuccessStatusCode)
30+
using (var response = await client.SendAsync(message, HttpCompletionOption.ResponseHeadersRead))
3231
{
33-
var content = await response.Content.ReadAsStringAsync();
34-
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(content);
35-
var e = new SupabaseStorageException(errorResponse?.Message ?? content)
32+
if (!response.IsSuccessStatusCode)
3633
{
37-
Content = content,
38-
Response = response,
39-
StatusCode = errorResponse?.StatusCode ?? (int)response.StatusCode
40-
};
34+
var content = await response.Content.ReadAsStringAsync();
35+
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(content);
36+
var e = new SupabaseStorageException(errorResponse?.Message ?? content)
37+
{
38+
Content = content,
39+
Response = response,
40+
StatusCode = errorResponse?.StatusCode ?? (int)response.StatusCode
41+
};
4142

42-
e.AddReason();
43-
throw e;
44-
}
43+
e.AddReason();
44+
throw e;
45+
}
4546

46-
var contentLength = response.Content.Headers.ContentLength;
47-
using var download = await response.Content.ReadAsStreamAsync();
48-
49-
// no progress... no contentLength... very sad
50-
if (progress is null || !contentLength.HasValue)
51-
{
52-
await download.CopyToAsync(destination);
53-
return destination;
47+
var contentLength = response.Content.Headers.ContentLength;
48+
using (var download = await response.Content.ReadAsStreamAsync())
49+
{
50+
// no progress... no contentLength... very sad
51+
if (progress is null || !contentLength.HasValue)
52+
{
53+
await download.CopyToAsync(destination);
54+
return destination;
55+
}
56+
57+
// Such progress and contentLength much reporting Wow!
58+
var progressWrapper = new Progress<long>(totalBytes => progress.Report(GetProgressPercentage(totalBytes, contentLength.Value)));
59+
await download.CopyToAsync(destination, 81920, progressWrapper, cancellationToken);
60+
}
5461
}
5562

56-
// Such progress and contentLength much reporting Wow!
57-
var progressWrapper = new Progress<long>(totalBytes => progress.Report(GetProgressPercentage(totalBytes, contentLength.Value)));
58-
await download.CopyToAsync(destination, 81920, progressWrapper, cancellationToken);
59-
6063
float GetProgressPercentage(float totalBytes, float currentBytes) => (totalBytes / currentBytes) * 100f;
6164

6265
return destination;

Storage/Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static async Task<HttpResponseMessage> MakeRequest(HttpMethod method, str
8686
requestMessage.Headers.TryAddWithoutValidation(kvp.Key, kvp.Value);
8787
}
8888

89-
using var response = await HttpRequestClient!.SendAsync(requestMessage, cancellationToken).ConfigureAwait(false);
89+
var response = await HttpRequestClient!.SendAsync(requestMessage, cancellationToken);
9090

9191
var content = await response.Content.ReadAsStringAsync();
9292

0 commit comments

Comments
 (0)