wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 17  →  ?path2? @ 16
/Web/wasHTTPClient.cs
@@ -11,7 +11,6 @@
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using wasSharp.Collections.Utilities;
 
namespace wasSharp.Web
{
@@ -63,29 +62,13 @@
{
HTTPClient.DefaultRequestHeaders.Authorization = authentication;
}
// Add some standard headers:
// Accept - for socially acceptable security of mod_sec
// Accept-Encoding - since we want to use compression if possible
switch (headers != null)
if (headers != null)
{
case false:
headers = new Dictionary<string, string> {{"Accept", @"*/*"}, {"Accept-Encoding", "gzip,defalate"}};
break;
default:
if (!headers.ContainsKey("Accept"))
{
headers.Add("Accept", @"*/*");
}
if (!headers.ContainsKey("Accept-Encoding"))
{
headers.Add("Accept-Encoding", "gzip,deflate");
}
break;
foreach (var header in headers)
{
HTTPClient.DefaultRequestHeaders.Add(header.Key, header.Value);
}
}
foreach (var header in headers)
{
HTTPClient.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HTTPClient.Timeout = TimeSpan.FromMilliseconds(timeout);
MediaType = mediaType;
}
@@ -117,17 +100,6 @@
{
request.Headers.Add(header.Key, header.Value);
}
// Add some standard headers:
// Accept - for socially acceptable security of mod_sec
// Accept-Encoding - since we want to use compression if possible
if (!headers.ContainsKey("Accept"))
{
headers.Add("Accept", @"*/*");
}
if (!headers.ContainsKey("Accept-Encoding"))
{
headers.Add("Accept-Encoding", "gzip,deflate");
}
using (var response = await HTTPClient.SendAsync(request))
{
return response.IsSuccessStatusCode
@@ -171,17 +143,6 @@
{
request.Headers.Add(header.Key, header.Value);
}
// Add some standard headers:
// Accept - for socially acceptable security of mod_sec
// Accept-Encoding - since we want to use compression if possible
if (!headers.ContainsKey("Accept"))
{
headers.Add("Accept", @"*/*");
}
if (!headers.ContainsKey("Accept-Encoding"))
{
headers.Add("Accept-Encoding", "gzip,deflate");
}
using (var response = await HTTPClient.SendAsync(request))
{
return response.IsSuccessStatusCode
@@ -331,7 +292,8 @@
 
public void Dispose()
{
HTTPClient?.Dispose();
if (HTTPClient != null)
HTTPClient.Dispose();
}
}
}