mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
when validating URLs, use HEAD requests to save bandwidth
This commit is contained in:
parent
4c5698472f
commit
b8bd642fad
1 changed files with 4 additions and 2 deletions
|
|
@ -71,7 +71,8 @@ private TransformBlock<Uri, UrlValidationResult> BuildValidator(CancellationToke
|
|||
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync(u, cancellationToken);
|
||||
var response = await _httpClient.GetAsync(u, HttpCompletionOption.ResponseHeadersRead,
|
||||
cancellationToken);
|
||||
if (u.Scheme == Uri.UriSchemeHttp && await IsHttpsSupported(u, cancellationToken))
|
||||
result.SetSupportsHttps();
|
||||
if (response.IsSuccessStatusCode)
|
||||
|
|
@ -117,7 +118,8 @@ private async Task<bool> IsHttpsSupported(Uri url, CancellationToken cancellatio
|
|||
var httpsUrl = new UriBuilder(url.OriginalString) {Scheme = Uri.UriSchemeHttps}.Uri;
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync(httpsUrl, cancellationToken);
|
||||
var response = await _httpClient.GetAsync(httpsUrl, HttpCompletionOption.ResponseHeadersRead,
|
||||
cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
return true;
|
||||
_logger.LogError(
|
||||
|
|
|
|||
Loading…
Reference in a new issue