mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Dispose httprequestmessage
This commit is contained in:
parent
4c971ed161
commit
5ecc276cb7
1 changed files with 101 additions and 97 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue