diff options
| author | 7illusions <z@7illusions.com> | 2014-05-12 16:55:07 +0200 |
|---|---|---|
| committer | 7illusions <z@7illusions.com> | 2014-05-12 16:55:07 +0200 |
| commit | baf5cf2544fcaad2246923f60caaf3fed4a94aaf (patch) | |
| tree | a808b700095f876e437b95c432c0220e241f9fda /MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | |
| parent | 8f3a6279e173dcbaaa05a56556afb410ee12dd4d (diff) | |
| parent | b9b568de13d81f9db1a8502d50940475c1d79c72 (diff) | |
Merge pull request #3 from MediaBrowser/master
Sync with Master
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 69533ef9d..0a9f0ff8a 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -114,9 +114,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None; - request.CachePolicy = options.CachePolicy == Net.HttpRequestCachePolicy.None ? - new RequestCachePolicy(RequestCacheLevel.BypassCache) : - new RequestCachePolicy(RequestCacheLevel.Revalidate); + request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); request.ConnectionGroupName = GetHostFromUrl(options.Url); request.KeepAlive = true; @@ -124,6 +122,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.Pipelined = true; request.Timeout = 20000; + if (!string.IsNullOrEmpty(options.Host)) + { + request.Host = options.Host; + } + #if !__MonoCS__ // This is a hack to prevent KeepAlive from getting disabled internally by the HttpWebRequest // May need to remove this for mono @@ -230,12 +233,15 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager var httpWebRequest = GetRequest(options, httpMethod, options.EnableHttpCompression); - if (!string.IsNullOrEmpty(options.RequestContent) || string.Equals(httpMethod, "post", StringComparison.OrdinalIgnoreCase)) + if (options.RequestContentBytes != null || + !string.IsNullOrEmpty(options.RequestContent) || + string.Equals(httpMethod, "post", StringComparison.OrdinalIgnoreCase)) { - var content = options.RequestContent ?? string.Empty; - var bytes = Encoding.UTF8.GetBytes(content); + var bytes = options.RequestContentBytes ?? + Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; + httpWebRequest.ContentLength = bytes.Length; httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length); } |
