Skip to content

Commit

Permalink
WikiClient: Preset AutomaticDecompression to All (Supports brotoli).
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Aug 31, 2024
1 parent 5b505a5 commit 16e542d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions WikiClientLibrary/Client/WikiClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Net;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using WikiClientLibrary.Infrastructures;
Expand Down Expand Up @@ -33,7 +34,7 @@ public WikiClient() : this(new HttpClientHandler(), true)
// Bots eat up a lot of bandwidth, which is not free.
if (_HttpClientHandler.SupportsAutomaticDecompression)
{
_HttpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
_HttpClientHandler.AutomaticDecompression = DecompressionMethods.All;
}
}

Expand All @@ -53,7 +54,7 @@ public WikiClient(HttpMessageHandler handler, bool disposeHandler)
ClientUserAgent = null;
_HttpClientHandler = handler as HttpClientHandler;
#if DEBUG
HttpClient.DefaultRequestHeaders.Add("X-WCL-DEBUG-CLIENT-ID", GetHashCode().ToString());
HttpClient.DefaultRequestHeaders.Add("X-WCL-DEBUG-CLIENT-ID", RuntimeHelpers.GetHashCode(this).ToString());
#endif
}

Expand Down Expand Up @@ -147,17 +148,15 @@ public async Task<T> InvokeAsync<T>(string endPointUrl, WikiRequestMessage messa
{
if (endPointUrl == null) throw new ArgumentNullException(nameof(endPointUrl));
if (message == null) throw new ArgumentNullException(nameof(message));
using (this.BeginActionScope(null, message))
{
var result = await SendAsync(endPointUrl, message, responseParser, cancellationToken);
return result;
}
using var scope = this.BeginActionScope(null, message);
var result = await SendAsync(endPointUrl, message, responseParser, cancellationToken);
return result;
}

/// <inheritdoc />
public override string ToString()
{
return $"{GetType().Name}#{GetHashCode()}";
return $"{GetType().Name}#{RuntimeHelpers.GetHashCode(this)}";
}

/// <summary>
Expand Down

0 comments on commit 16e542d

Please sign in to comment.