diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-10-22 16:31:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-22 16:31:23 -0400 |
| commit | 165b4c2fb8868045cd9dae3f00280e1c7b513acb (patch) | |
| tree | 47a53e6922e3061c7228daa73fb21b72b1e2806e /MediaBrowser.Common.Implementations/HttpClientManager | |
| parent | 3c1114228ba3b6a19cb73fa7f9aaa4e3ce3cab80 (diff) | |
| parent | ce47beba842dc026483dc3649a1efb8c34b30662 (diff) | |
Merge pull request #2251 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager')
| -rw-r--r-- | MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index eec18e985..063529cfc 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -342,7 +342,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager ResponseUrl = url, Content = memoryStream, StatusCode = HttpStatusCode.OK, - Headers = new NameValueCollection(), ContentLength = memoryStream.Length }; } @@ -487,7 +486,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, Stream content, long? contentLength, IDisposable disposable) { - return new HttpResponseInfo(disposable) + var responseInfo = new HttpResponseInfo(disposable) { Content = content, @@ -495,17 +494,22 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager ContentType = httpResponse.ContentType, - Headers = new NameValueCollection(httpResponse.Headers), - ContentLength = contentLength, ResponseUrl = httpResponse.ResponseUri.ToString() }; + + if (httpResponse.Headers != null) + { + SetHeaders(httpResponse.Headers, responseInfo); + } + + return responseInfo; } private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, string tempFile, long? contentLength) { - return new HttpResponseInfo + var responseInfo = new HttpResponseInfo { TempFilePath = tempFile, @@ -513,10 +517,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager ContentType = httpResponse.ContentType, - Headers = httpResponse.Headers, - ContentLength = contentLength }; + + if (httpResponse.Headers != null) + { + SetHeaders(httpResponse.Headers, responseInfo); + } + + return responseInfo; + } + + private void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo) + { + foreach (var key in headers.AllKeys) + { + responseInfo.Headers[key] = headers[key]; + } } public Task<HttpResponseInfo> Post(HttpRequestOptions options) |
