Dispose httprequestmessage

This commit is contained in:
Luke Pulverenti 2013-05-18 14:58:16 -04:00
parent 4c971ed161
commit 5ecc276cb7

View file

@ -136,8 +136,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
var now = DateTime.UtcNow;
var isCacheValid = (!cachedInfo.MustRevalidate && !string.IsNullOrEmpty(cachedInfo.Etag) && (now - cachedInfo.RequestDate).TotalDays < 7)
|| (cachedInfo.Expires.HasValue && cachedInfo.Expires.Value > now);
var isCacheValid = cachedInfo.Expires.HasValue ? cachedInfo.Expires.Value > now :
!cachedInfo.MustRevalidate && !string.IsNullOrEmpty(cachedInfo.Etag) && (now - cachedInfo.RequestDate).TotalDays < 5;
if (isCacheValid)
{
@ -157,8 +157,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
options.CancellationToken.ThrowIfCancellationRequested();
var message = GetHttpRequestMessage(options);
using (var message = GetHttpRequestMessage(options))
{
if (options.EnableResponseCache && cachedInfo != null)
{
if (!string.IsNullOrEmpty(cachedInfo.Etag))
@ -243,6 +243,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
}
}
}
}
/// <summary>
/// Performs a GET request and returns the resulting stream
@ -469,7 +470,9 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
options.CancellationToken.ThrowIfCancellationRequested();
using (var response = await GetHttpClient(GetHostFromUrl(options.Url)).SendAsync(GetHttpRequestMessage(options), HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false))
using (var message = GetHttpRequestMessage(options))
{
using (var response = await GetHttpClient(GetHostFromUrl(options.Url)).SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false))
{
EnsureSuccessStatusCode(response);
@ -504,6 +507,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
options.CancellationToken.ThrowIfCancellationRequested();
}
}
}
catch (Exception ex)
{
HandleTempFileException(ex, options, tempFile);