-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored RuriLib.Http and RuriLib.Http.Tests
Also added missing comma-separated cookies handling logic
- Loading branch information
1 parent
3ef3277
commit 479e1b9
Showing
16 changed files
with
2,133 additions
and
2,125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace RuriLib.Http.Exceptions; | ||
|
||
/// <summary> | ||
/// An exception that is thrown when an HTTP request fails. | ||
/// </summary> | ||
public class RLHttpException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates an RLHttpException with a <paramref name="message"/>. | ||
/// </summary> | ||
public RLHttpException(string message) : base(message) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace RuriLib.Http.Extensions | ||
namespace RuriLib.Http.Extensions; | ||
|
||
internal static class ListExtensions | ||
{ | ||
static internal class IListExtensions | ||
{ | ||
public static void Add(this IList<KeyValuePair<string, string>> list, string key, object value) | ||
=> list.Add(new KeyValuePair<string, string>(key, value.ToString())); | ||
} | ||
public static void Add(this IList<KeyValuePair<string, string>> list, string key, object value) | ||
=> list.Add(new KeyValuePair<string, string>(key, value.ToString()!)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace RuriLib.Http.Helpers | ||
namespace RuriLib.Http.Helpers; | ||
|
||
internal static class ContentHelper | ||
{ | ||
static internal class ContentHelper | ||
{ | ||
//https://github.com/dotnet/corefx/blob/3e72ee5971db5d0bd46606fa672969adde29e307/src/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs | ||
private static readonly string[] contentHeaders = new [] | ||
{ | ||
"Last-Modified", | ||
"Expires", | ||
"Content-Type", | ||
"Content-Range", | ||
"Content-MD5", | ||
"Content-Location", | ||
"Content-Length", | ||
"Content-Language", | ||
"Content-Encoding", | ||
"Allow" | ||
}; | ||
//https://github.com/dotnet/corefx/blob/3e72ee5971db5d0bd46606fa672969adde29e307/src/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs | ||
private static readonly string[] _contentHeaders = | ||
[ | ||
"Last-Modified", | ||
"Expires", | ||
"Content-Type", | ||
"Content-Range", | ||
"Content-MD5", | ||
"Content-Location", | ||
"Content-Length", | ||
"Content-Language", | ||
"Content-Encoding", | ||
"Allow" | ||
]; | ||
|
||
public static bool IsContentHeader(string name) => contentHeaders.Any(h => h.Equals(name, StringComparison.OrdinalIgnoreCase)); | ||
} | ||
public static bool IsContentHeader(string name) => _contentHeaders.Any(h => h.Equals(name, StringComparison.OrdinalIgnoreCase)); | ||
} |
Oops, something went wrong.