Dispose httprequestmessage

pull/702/head
Luke Pulverenti 12 years ago
parent 4c971ed161
commit 5ecc276cb7

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

Loading…
Cancel
Save