dispose of IDisposable w/using

This commit is contained in:
Collin M. Barrett 2019-07-11 08:37:37 -05:00
parent 7a0b05ac2a
commit 40b6bf4406

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
@ -74,7 +73,7 @@ public async Task<UrlValidationResult> ValidateAsync(Uri u, CancellationToken ca
try
{
var response =
using var response =
await _httpClient.GetAsync(u, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
if (u.Scheme == Uri.UriSchemeHttp && await IsHttpsSupported(u, cancellationToken))
result.SetSupportsHttps();
@ -118,7 +117,7 @@ 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, HttpCompletionOption.ResponseHeadersRead,
using var response = await _httpClient.GetAsync(httpsUrl, HttpCompletionOption.ResponseHeadersRead,
cancellationToken);
if (response.IsSuccessStatusCode)
return true;