diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-21 22:08:34 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-21 22:08:34 -0400 |
| commit | c7f559f8cefa4c4b90df3bff72290c8bd5b18e01 (patch) | |
| tree | 4d26b4995e7df5d44c39d76ba58db66f1e48dbc4 /MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | |
| parent | f8c603d5ebc28e03140df4f1b155c97b387f09a5 (diff) | |
make model project portable
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
| -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) |
