Skip to content

Enable HttpClient in-flight compression for static files and OpenApiWithOpenIdConnect #232

@ddemeyer

Description

@ddemeyer

Any .svc SOAP call under protocol WcfSoapWithOpenIdConnect and deprecated WcfSoapWithWsTrust will do HTTP requests where the result from the SOAP web services is expected to be compressed which greatly saves transfer times on virtually longer network cables. Currently an OpenAPI REST call returns an uncompressed JSON model which can be 98072 bytes, while gzip compressed it is 11564.

This issue is about enabling this for the non-soap HTTP calls, in particular

  • While discovering the web services over connectionconfiguration.xml
  • While using protocol OpenApiWithOpenIdConnect which are using an HttpClient with bearer token, available under $ishSession.OpenApiISH30Client

Do note that even though the client requests this encoding, it still is up to the server to support or eventually do the encoding.

  1. ISHRemote under Windows PowerShell 5.1 hosted on .NET Framework 4.8 only supports gzip and deflate.
  2. Cross-platform PowerShell 7.x hosted on .NET 6+ additionally supports br (Brotli).
  3. Future PowerShell 7.7 hosted on .NET11 holds Add DecompressionMethods.Zstandard for HTTP automatic decompression by Copilot · Pull Request #123531 · dotnet/runtime

Given that the release of v8.2 is due soon, await to push this change for early v8.3 to offer some stabilization.

Actions...

  • Edit IshSession.cs
  • Edit InfoShareWcfSoapWithOpenIdConnectConnection.cs
  • Edit InfoShareWcfSoapWithWsTrustConnection.cs, although deprecated for consistency.
  • Test on Windows-based IIS-hosted Tridion Docs from PowerShell 5.1 and PowerShell 7.6
  • Test on Linux-based Kestrel-hosted Tridion Docs from PowerShell 5.1 and PowerShell 7.6

Expected code change...

#if NET48
            handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
#else
            handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli;
#endif

            _httpClient = new HttpClient(handler)
            {
                Timeout = _timeout
            };
#if NET48
            _httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("gzip");
            _httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("deflate");
#else
            _httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("gzip");
            _httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("deflate");
            _httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("br");
#endif

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions