Skip to content

Commit

Permalink
cleanup http code
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jun 18, 2024
1 parent 66d323c commit 4b0700d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/http/interfaces/IHTTP.ClientResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public interface ClientResponse
/// Native Response Object
/// </summary>
HttpResponseMessage NativeResponse { get; }

/// <summary>
/// Native Client Object
/// </summary>
HttpClient NativeClient { get; }

/// <summary>
/// Response encoding
/// </summary>
Expand All @@ -32,12 +32,12 @@ public interface ClientResponse
/// Response Queries
/// </summary>
Dictionary<string, string> Queries { get; }

/// <summary>
/// Request Http Method
/// </summary>
HttpMethod Method { get; }

/// <summary>
/// Response Enctype
/// </summary>
Expand Down Expand Up @@ -67,7 +67,7 @@ public interface ClientResponse
/// Request Body
/// </summary>
Body Body { get; }

/// <summary>
/// Http Status Code. <br />
/// if value is -1 mean: (not applicable on context).
Expand Down
8 changes: 4 additions & 4 deletions src/http/partials/Client/HTTP.ClientResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private Encoding GetEncodingFromHeader()
if (key.Contains("ASCII")) return Encoding.ASCII;
if (key.Contains("UTF-16")) return Encoding.Unicode;
if (key.Contains("UTF-32")) return Encoding.UTF32;

// https://en.wikipedia.org/wiki/Character_encodings_in_HTML
return Encoding.UTF8;
}
Expand All @@ -105,13 +105,13 @@ private Enctype GetEnctypeFromHeader()
var comparisonType = StringComparison.InvariantCultureIgnoreCase;
var value = Headers.FirstOrDefault(x => x.Key.Equals("Content-Type", comparisonType));
var key = (value.Value ?? string.Empty).ToUpper();

if (string.IsNullOrWhiteSpace(key)) return Enctype.None;

if (key.Contains("application/x-www-form-urlencoded")) return Enctype.UrlEncoded;
if (key.Contains("multipart/form-data")) return Enctype.Multipart;
if (key.Contains("text/plain")) return Enctype.PlainText;

return Enctype.None;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/http/partials/Client/HTTP.ClientTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Task Open(string method, string url, byte[] body = null)
var host = new Uri(url);

var timeout = _timeout <= 0
? System.Threading.Timeout.InfiniteTimeSpan
? Timeout.InfiniteTimeSpan
: TimeSpan.FromMilliseconds(_timeout);

var httpMethod = new HttpMethod(method.Trim().ToUpper());
Expand Down Expand Up @@ -130,7 +130,7 @@ public Task Open(string method, string url, string body, Encoding encode)

public Task Close()
{
_cancellationToken.Cancel(throwOnFirstException: true);
_cancellationToken.Cancel(true);
return Task.CompletedTask;
}

Expand Down

0 comments on commit 4b0700d

Please sign in to comment.