mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
update to service stack 3.0.70.0
This commit is contained in:
@@ -27,7 +27,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
/// <summary>
|
||||
/// When one request to a host times out, we'll ban all other requests for this period of time, to prevent scans from stalling
|
||||
/// </summary>
|
||||
private int TimeoutSeconds = 30;
|
||||
private const int TimeoutSeconds = 30;
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
@@ -42,16 +42,14 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpClientManager"/> class.
|
||||
/// Initializes a new instance of the <see cref="HttpClientManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="appPaths">The app paths.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="getHttpClientHandler">The get HTTP client handler.</param>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// appPaths
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <exception cref="System.ArgumentNullException">appPaths
|
||||
/// or
|
||||
/// logger
|
||||
/// </exception>
|
||||
/// logger</exception>
|
||||
public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
if (appPaths == null)
|
||||
@@ -143,7 +141,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
/// Gets the response internal.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="httpMethod">The HTTP method.</param>
|
||||
/// <returns>Task{HttpResponseInfo}.</returns>
|
||||
/// <exception cref="HttpException">
|
||||
/// </exception>
|
||||
@@ -490,27 +487,19 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
var exception = GetCancellationException(options.Url, options.CancellationToken, ex);
|
||||
|
||||
throw exception;
|
||||
throw GetTempFileException(ex, options, tempFile);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||
|
||||
throw new HttpException(ex.Message, ex);
|
||||
throw GetTempFileException(ex, options, tempFile);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||
|
||||
throw new HttpException(ex.Message, ex);
|
||||
throw GetTempFileException(ex, options, tempFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||
|
||||
throw;
|
||||
throw GetTempFileException(ex, options, tempFile);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -521,65 +510,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <returns>HttpResponseMessage.</returns>
|
||||
private HttpRequestMessage GetHttpRequestMessage(HttpRequestOptions options)
|
||||
{
|
||||
var message = new HttpRequestMessage(HttpMethod.Get, options.Url);
|
||||
|
||||
foreach (var pair in options.RequestHeaders.ToList())
|
||||
{
|
||||
if (!message.Headers.TryAddWithoutValidation(pair.Key, pair.Value))
|
||||
{
|
||||
_logger.Error("Unable to add request header {0} with value {1}", pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the content.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <returns>System.Nullable{System.Int64}.</returns>
|
||||
private long? GetContentLength(HttpResponseMessage response)
|
||||
{
|
||||
IEnumerable<string> lengthValues = null;
|
||||
|
||||
// Seeing some InvalidOperationException here under mono
|
||||
try
|
||||
{
|
||||
response.Headers.TryGetValues("content-length", out lengthValues);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.ErrorException("Error accessing response.Headers.TryGetValues Content-Length", ex);
|
||||
}
|
||||
|
||||
if (lengthValues == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
response.Content.Headers.TryGetValues("content-length", out lengthValues);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.ErrorException("Error accessing response.Content.Headers.TryGetValues Content-Length", ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (lengthValues == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return long.Parse(string.Join(string.Empty, lengthValues.ToArray()), UsCulture);
|
||||
}
|
||||
|
||||
private long? GetContentLength(HttpWebResponse response)
|
||||
{
|
||||
var length = response.ContentLength;
|
||||
@@ -616,16 +546,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
|
||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||
|
||||
var httpRequestException = ex as HttpRequestException;
|
||||
|
||||
// Cleanup
|
||||
DeleteTempFile(tempFile);
|
||||
|
||||
var httpRequestException = ex as HttpRequestException;
|
||||
|
||||
if (httpRequestException != null)
|
||||
{
|
||||
return new HttpException(ex.Message, ex);
|
||||
}
|
||||
|
||||
var webException = ex as WebException;
|
||||
|
||||
if (webException != null)
|
||||
{
|
||||
return new HttpException(ex.Message, ex);
|
||||
}
|
||||
|
||||
return ex;
|
||||
}
|
||||
|
||||
@@ -711,19 +648,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||
return exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the success status code.
|
||||
/// </summary>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
|
||||
private void EnsureSuccessStatusCode(HttpResponseMessage response)
|
||||
{
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new HttpException(response.ReasonPhrase) { StatusCode = response.StatusCode };
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSuccessStatusCode(HttpWebResponse response)
|
||||
{
|
||||
var statusCode = response.StatusCode;
|
||||
|
||||
@@ -41,6 +41,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NLog.2.1.0\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ServiceStack.Text, Version=3.9.70.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpCompress">
|
||||
<HintPath>..\packages\sharpcompress.0.10.1.3\lib\net40\SharpCompress.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -55,9 +59,6 @@
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="ServiceStack.Text">
|
||||
<HintPath>..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SharedVersion.cs">
|
||||
|
||||
@@ -169,6 +169,8 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
||||
ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601;
|
||||
ServiceStack.Text.JsConfig.ExcludeTypeInfo = true;
|
||||
ServiceStack.Text.JsConfig.IncludeNullValues = false;
|
||||
ServiceStack.Text.JsConfig.AlwaysUseUtc = true;
|
||||
ServiceStack.Text.JsConfig.AssumeUtc = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="2.1.0" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.70" targetFramework="net45" />
|
||||
<package id="sharpcompress" version="0.10.1.3" targetFramework="net45" />
|
||||
<package id="SimpleInjector" version="2.3.6" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user