diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-04-08 00:17:18 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-04-08 00:17:18 -0400 |
| commit | 2c6a9892f2082c6a288ba01033f3fd7d517fa92e (patch) | |
| tree | 3a3e4bcbbcb20fc4c6fc326cc6452bb0957de938 /MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | |
| parent | 63aea3d90836765ceb38f0b9b130970af9b132d9 (diff) | |
update translations
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | 52 |
1 files changed, 38 insertions, 14 deletions
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 /// </summary> /// <param name="options">The options.</param> /// <returns>Task{HttpResponseInfo}.</returns> - /// <exception cref="HttpException"> - /// </exception> public Task<HttpResponseInfo> GetResponse(HttpRequestOptions options) { return SendAsync(options, "GET"); @@ -174,8 +172,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// </summary> /// <param name="options">The options.</param> /// <returns>Task{Stream}.</returns> - /// <exception cref="HttpException"></exception> - /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception> public async Task<Stream> 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 } } + /// <summary> + /// Gets the exception. + /// </summary> + /// <param name="ex">The ex.</param> + /// <param name="options">The options.</param> + /// <returns>HttpException.</returns> + 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 /// <param name="options">The options.</param> /// <param name="postData">Params to add to the POST data.</param> /// <returns>stream on success, null on failure</returns> - /// <exception cref="HttpException"> - /// </exception> - /// <exception cref="System.ArgumentNullException">postData</exception> - /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception> public async Task<Stream> Post(HttpRequestOptions options, Dictionary<string, string> postData) { var strings = postData.Keys.Select(key => string.Format("{0}={1}", key, postData[key])); @@ -426,8 +452,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// <param name="options">The options.</param> /// <returns>Task{System.String}.</returns> /// <exception cref="System.ArgumentNullException">progress</exception> - /// <exception cref="HttpException"></exception> - /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception> public async Task<string> 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; |
