aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-05-24 15:12:55 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-05-24 15:12:55 -0400
commitf07af448fa11330db93dd7ddcabac37ef9e014c7 (patch)
tree1b52a4f73d674a48258c2f14c94117b96ca4a678 /Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
parent27c3acb2bfde9025c33f584c759a4038020cb702 (diff)
update main projects
Diffstat (limited to 'Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs')
-rw-r--r--Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs36
1 files changed, 0 insertions, 36 deletions
diff --git a/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
index eb9bc1bd0..c2a310c0e 100644
--- a/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -66,13 +66,11 @@ namespace Emby.Common.Implementations.HttpClientManager
_appPaths = appPaths;
_defaultUserAgentFn = defaultUserAgentFn;
-#if NET46
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
ServicePointManager.Expect100Continue = false;
// Trakt requests sometimes fail without this
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
-#endif
}
/// <summary>
@@ -129,7 +127,6 @@ namespace Emby.Common.Implementations.HttpClientManager
private void AddIpv4Option(HttpWebRequest request, HttpRequestOptions options)
{
-#if NET46
request.ServicePoint.BindIPEndPointDelegate = (servicePount, remoteEndPoint, retryCount) =>
{
if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
@@ -138,7 +135,6 @@ namespace Emby.Common.Implementations.HttpClientManager
}
throw new InvalidOperationException("no IPv4 address");
};
-#endif
}
private WebRequest GetRequest(HttpRequestOptions options, string method)
@@ -165,7 +161,6 @@ namespace Emby.Common.Implementations.HttpClientManager
AddRequestHeaders(httpWebRequest, options);
-#if NET46
if (options.EnableHttpCompression)
{
if (options.DecompressionMethod.HasValue)
@@ -183,48 +178,33 @@ namespace Emby.Common.Implementations.HttpClientManager
{
httpWebRequest.AutomaticDecompression = DecompressionMethods.None;
}
-#endif
}
-#if NET46
request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
-#endif
if (httpWebRequest != null)
{
if (options.EnableKeepAlive)
{
-#if NET46
httpWebRequest.KeepAlive = true;
-#endif
}
}
request.Method = method;
-#if NET46
request.Timeout = options.TimeoutMs;
-#endif
if (httpWebRequest != null)
{
if (!string.IsNullOrEmpty(options.Host))
{
-#if NET46
httpWebRequest.Host = options.Host;
-#elif NETSTANDARD1_6
- httpWebRequest.Headers["Host"] = options.Host;
-#endif
}
if (!string.IsNullOrEmpty(options.Referer))
{
-#if NET46
httpWebRequest.Referer = options.Referer;
-#elif NETSTANDARD1_6
- httpWebRequest.Headers["Referer"] = options.Referer;
-#endif
}
}
@@ -235,9 +215,7 @@ namespace Emby.Common.Implementations.HttpClientManager
{
request.Credentials = GetCredential(url, parts[0], parts[1]);
// TODO: .net core ??
-#if NET46
request.PreAuthenticate = true;
-#endif
}
}
@@ -269,11 +247,7 @@ namespace Emby.Common.Implementations.HttpClientManager
}
else
{
-#if NET46
request.Headers.Set(header.Key, header.Value);
-#elif NETSTANDARD1_6
- request.Headers[header.Key] = header.Value;
-#endif
}
}
@@ -285,11 +259,7 @@ namespace Emby.Common.Implementations.HttpClientManager
private void SetUserAgent(HttpWebRequest request, string userAgent)
{
-#if NET46
request.UserAgent = userAgent;
-#elif NETSTANDARD1_6
- request.Headers["User-Agent"] = userAgent;
-#endif
}
/// <summary>
@@ -465,9 +435,7 @@ namespace Emby.Common.Implementations.HttpClientManager
httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded";
-#if NET46
httpWebRequest.ContentLength = bytes.Length;
-#endif
(await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length);
}
catch (Exception ex)
@@ -950,7 +918,6 @@ namespace Emby.Common.Implementations.HttpClientManager
private Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
{
-#if NET46
var taskCompletion = new TaskCompletionSource<WebResponse>();
Task<WebResponse> asyncTask = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);
@@ -963,9 +930,6 @@ namespace Emby.Common.Implementations.HttpClientManager
asyncTask.ContinueWith(callback.OnError, TaskContinuationOptions.OnlyOnFaulted);
return taskCompletion.Task;
-#endif
-
- return request.GetResponseAsync();
}
private static void TimeoutCallback(object state, bool timedOut)