|
|
@ -270,7 +270,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|
|
|
|
|
|
|
|
|
|
|
var httpResponse = (HttpWebResponse)response;
|
|
|
|
var httpResponse = (HttpWebResponse)response;
|
|
|
|
|
|
|
|
|
|
|
|
EnsureSuccessStatusCode(httpResponse);
|
|
|
|
EnsureSuccessStatusCode(httpResponse, options);
|
|
|
|
|
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
|
@ -281,7 +281,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var httpResponse = (HttpWebResponse)response;
|
|
|
|
var httpResponse = (HttpWebResponse)response;
|
|
|
|
|
|
|
|
|
|
|
|
EnsureSuccessStatusCode(httpResponse);
|
|
|
|
EnsureSuccessStatusCode(httpResponse, options);
|
|
|
|
|
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
|
@ -345,29 +345,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
|
|
|
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
|
|
|
|
|
|
|
|
|
|
|
if (options.LogErrorResponseBody)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (var stream = ex.Response.GetResponseStream())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (stream != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (var reader = new StreamReader(stream))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var msg = reader.ReadToEnd();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Error(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpException(ex.Message, ex);
|
|
|
|
return new HttpException(ex.Message, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -496,7 +473,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var httpResponse = (HttpWebResponse)response;
|
|
|
|
var httpResponse = (HttpWebResponse)response;
|
|
|
|
|
|
|
|
|
|
|
|
EnsureSuccessStatusCode(httpResponse);
|
|
|
|
EnsureSuccessStatusCode(httpResponse, options);
|
|
|
|
|
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
|
@ -686,13 +663,35 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|
|
|
return exception;
|
|
|
|
return exception;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EnsureSuccessStatusCode(HttpWebResponse response)
|
|
|
|
private void EnsureSuccessStatusCode(HttpWebResponse response, HttpRequestOptions options)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var statusCode = response.StatusCode;
|
|
|
|
var statusCode = response.StatusCode;
|
|
|
|
var isSuccessful = statusCode >= HttpStatusCode.OK && statusCode <= (HttpStatusCode)299;
|
|
|
|
var isSuccessful = statusCode >= HttpStatusCode.OK && statusCode <= (HttpStatusCode)299;
|
|
|
|
|
|
|
|
|
|
|
|
if (!isSuccessful)
|
|
|
|
if (!isSuccessful)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (options.LogErrorResponseBody)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (var stream = response.GetResponseStream())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (stream != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (var reader = new StreamReader(stream))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var msg = reader.ReadToEnd();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Error(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
throw new HttpException(response.StatusDescription) { StatusCode = response.StatusCode };
|
|
|
|
throw new HttpException(response.StatusDescription) { StatusCode = response.StatusCode };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|