mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Move http client compression to utilities
We don't really need standalone class, contrary to my first expectation
This commit is contained in:
@@ -830,7 +830,7 @@ public sealed class WebBrowser : IDisposable {
|
||||
if (requestOptions.HasFlag(ERequestOptions.CompressRequest) && (requestMessage.Content.Headers.ContentEncoding.Count == 0)) {
|
||||
HttpContent originalContent = requestMessage.Content;
|
||||
|
||||
requestMessage.Content = await CompressedContent.FromHttpContent(originalContent).ConfigureAwait(false);
|
||||
requestMessage.Content = await WebBrowserUtilities.CreateCompressedHttpContent(originalContent).ConfigureAwait(false);
|
||||
|
||||
if (data is not HttpContent) {
|
||||
// We don't need to keep old HttpContent around anymore, help GC
|
||||
|
||||
@@ -28,10 +28,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ArchiSteamFarm.Web;
|
||||
|
||||
internal sealed class CompressedContent : StreamContent {
|
||||
private CompressedContent(Stream content) : base(content) => ArgumentNullException.ThrowIfNull(content);
|
||||
|
||||
internal static async Task<CompressedContent> FromHttpContent(HttpContent content) {
|
||||
internal static class WebBrowserUtilities {
|
||||
internal static async Task<StreamContent> CreateCompressedHttpContent(HttpContent content) {
|
||||
ArgumentNullException.ThrowIfNull(content);
|
||||
|
||||
// We're going to create compressed stream and copy original content to it
|
||||
@@ -46,7 +44,7 @@ internal sealed class CompressedContent : StreamContent {
|
||||
// Reset the position back to 0, so HttpClient can read it again
|
||||
compressionOutput.Position = 0;
|
||||
|
||||
CompressedContent result = new(compressionOutput);
|
||||
StreamContent result = new(compressionOutput);
|
||||
|
||||
foreach ((string? key, IEnumerable<string>? value) in content.Headers) {
|
||||
result.Headers.Add(key, value);
|
||||
Reference in New Issue
Block a user