From c83995adc161c697776ad15cf895222c5baac62f Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Sat, 1 Dec 2018 16:55:26 +0100 Subject: [PATCH] Fixed: Resource leakage inside HttpClient. --- src/NzbDrone.Common/Http/HttpClient.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Common/Http/HttpClient.cs b/src/NzbDrone.Common/Http/HttpClient.cs index 2f985d552..1c234c427 100644 --- a/src/NzbDrone.Common/Http/HttpClient.cs +++ b/src/NzbDrone.Common/Http/HttpClient.cs @@ -226,11 +226,13 @@ namespace NzbDrone.Common.Http _logger.Debug("Downloading [{0}] to [{1}]", url, fileName); var stopWatch = Stopwatch.StartNew(); - var webClient = new GZipWebClient(); - webClient.Headers.Add(HttpRequestHeader.UserAgent, UserAgentBuilder.UserAgent); - webClient.DownloadFile(url, fileName); - stopWatch.Stop(); - _logger.Debug("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds); + using (var webClient = new GZipWebClient()) + { + webClient.Headers.Add(HttpRequestHeader.UserAgent, UserAgentBuilder.UserAgent); + webClient.DownloadFile(url, fileName); + stopWatch.Stop(); + _logger.Debug("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds); + } } catch (WebException e) {