From 2c6a9892f2082c6a288ba01033f3fd7d517fa92e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 8 Apr 2014 00:17:18 -0400 Subject: update translations --- .../HttpClientManager/HttpClientManager.cs | 52 ++++++++++++++++------ 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index ac9a51ea1..7fd7c8c1c 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -162,8 +162,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// /// The options. /// Task{HttpResponseInfo}. - /// - /// public Task GetResponse(HttpRequestOptions options) { return SendAsync(options, "GET"); @@ -174,8 +172,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// /// The options. /// Task{Stream}. - /// - /// public async Task Get(HttpRequestOptions options) { var response = await GetResponse(options).ConfigureAwait(false); @@ -322,9 +318,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } catch (WebException ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw new HttpException(ex.Message, ex); + throw GetException(ex, options); } catch (Exception ex) { @@ -341,6 +335,42 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } } + /// + /// Gets the exception. + /// + /// The ex. + /// The options. + /// HttpException. + private HttpException GetException(WebException ex, HttpRequestOptions options) + { + _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); + } + private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, Stream content, long? contentLength) { return new HttpResponseInfo @@ -384,10 +414,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// The options. /// Params to add to the POST data. /// stream on success, null on failure - /// - /// - /// postData - /// public async Task Post(HttpRequestOptions options, Dictionary postData) { var strings = postData.Keys.Select(key => string.Format("{0}={1}", key, postData[key])); @@ -426,8 +452,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// The options. /// Task{System.String}. /// progress - /// - /// public async Task GetTempFile(HttpRequestOptions options) { var response = await GetTempFileResponse(options).ConfigureAwait(false); @@ -580,7 +604,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager if (webException != null) { - return new HttpException(ex.Message, ex); + throw GetException(webException, options); } return ex; -- cgit v1.2.3