Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions PowerKit/Extensions/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static class HttpClientExtensions
/// Downloads the content at the specified URI to a local file.
/// </summary>
public async Task DownloadAsync(
string requestUri,
Uri requestUri,
string filePath,
IProgress<double>? progress = null,
CancellationToken cancellationToken = default
Expand All @@ -43,10 +43,27 @@ await response
}

/// <summary>
/// Sends a HEAD request to the specified URI and returns the response.
/// Downloads the content at the specified URI to a local file.
/// </summary>
public async ValueTask<HttpResponseMessage> HeadAsync(
public async Task DownloadAsync(
string requestUri,
string filePath,
IProgress<double>? progress = null,
CancellationToken cancellationToken = default
) =>
await http.DownloadAsync(
new Uri(requestUri, UriKind.RelativeOrAbsolute),
filePath,
progress,
cancellationToken
)
.ConfigureAwait(false);

/// <summary>
/// Sends a HEAD request to the specified URI and returns the response.
/// </summary>
public async Task<HttpResponseMessage> HeadAsync(
Uri requestUri,
CancellationToken cancellationToken = default
)
Comment thread
Tyrrrz marked this conversation as resolved.
{
Expand All @@ -58,6 +75,16 @@ public async ValueTask<HttpResponseMessage> HeadAsync(
)
.ConfigureAwait(false);
}

/// <summary>
/// Sends a HEAD request to the specified URI and returns the response.
/// </summary>
public async Task<HttpResponseMessage> HeadAsync(
string requestUri,
CancellationToken cancellationToken = default
) =>
await http.HeadAsync(new Uri(requestUri, UriKind.RelativeOrAbsolute), cancellationToken)
.ConfigureAwait(false);
}
}
#endif