aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
diff options
context:
space:
mode:
authorErwin de Haan <EraYaN@users.noreply.github.com>2019-01-06 21:50:43 +0100
committerErwin de Haan <EraYaN@users.noreply.github.com>2019-01-10 20:38:53 +0100
commitec1f5dc317182582ebff843c9e8a4d5277405469 (patch)
tree6514de336cc9aa94becb3fbd767285dfa61d0b1b /Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
parent3d867c2c46cec39b669bb8647efef677f32b8a8d (diff)
Mayor code cleanup
Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment.
Diffstat (limited to 'Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs')
-rw-r--r--Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs26
1 files changed, 13 insertions, 13 deletions
diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
index d3ba1b683..6494f0c6f 100644
--- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
@@ -48,11 +48,11 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (appPaths == null)
{
- throw new ArgumentNullException("appPaths");
+ throw new ArgumentNullException(nameof(appPaths));
}
if (logger == null)
{
- throw new ArgumentNullException("logger");
+ throw new ArgumentNullException(nameof(logger));
}
_logger = logger;
@@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (string.IsNullOrEmpty(host))
{
- throw new ArgumentNullException("host");
+ throw new ArgumentNullException(nameof(host));
}
HttpClientInfo client;
@@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.HttpClientManager
return client;
}
- private WebRequest CreateWebRequest(string url)
+ private static WebRequest CreateWebRequest(string url)
{
try
{
@@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.HttpClientManager
return request;
}
- private CredentialCache GetCredential(string url, string username, string password)
+ private static CredentialCache GetCredential(string url, string username, string password)
{
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
CredentialCache credentialCache = new CredentialCache();
@@ -220,7 +220,7 @@ namespace Emby.Server.Implementations.HttpClientManager
}
}
- private void SetUserAgent(HttpWebRequest request, string userAgent)
+ private static void SetUserAgent(HttpWebRequest request, string userAgent)
{
request.UserAgent = userAgent;
}
@@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.HttpClientManager
return responseInfo;
}
- private void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo)
+ private static void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo)
{
foreach (var key in headers.AllKeys)
{
@@ -541,7 +541,7 @@ namespace Emby.Server.Implementations.HttpClientManager
if (options.Progress == null)
{
- throw new ArgumentNullException("progress");
+ throw new ArgumentException("Options did not have a Progress value.",nameof(options));
}
options.CancellationToken.ThrowIfCancellationRequested();
@@ -616,7 +616,7 @@ namespace Emby.Server.Implementations.HttpClientManager
}
}
- private long? GetContentLength(HttpWebResponse response)
+ private static long? GetContentLength(HttpWebResponse response)
{
var length = response.ContentLength;
@@ -704,7 +704,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (string.IsNullOrEmpty(options.Url))
{
- throw new ArgumentNullException("options");
+ throw new ArgumentNullException(nameof(options));
}
}
@@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.HttpClientManager
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>System.String.</returns>
- private string GetHostFromUrl(string url)
+ private static string GetHostFromUrl(string url)
{
var index = url.IndexOf("://", StringComparison.OrdinalIgnoreCase);
@@ -803,7 +803,7 @@ namespace Emby.Server.Implementations.HttpClientManager
};
}
- private Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
+ private static Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
{
var taskCompletion = new TaskCompletionSource<WebResponse>();