Skip to content

[API Proposal]: DecompressionMethods.Zstd for web requests #112075

@MichalPetryka

Description

@MichalPetryka

Background and motivation

DecompressionMethods auto-decoding was last expanded with Brotli. Since then, some web servers started serving content using ZSTD compression instead. As such, it'd be appropriate for .NET to include the ability to handle such encoding out of the box.

CURL supports this starting with version 7.72.0, released in August 2020.
Cloudflare supports this since last September.

API Proposal

namespace System.Net;

[Flags]
public enum DecompressionMethods
{
    None = 0,
    All = ~None
    GZip = 0x1,
    Deflate = 0x2,
    Brotli = 0x4,
+   Zstandard = 0x8,
}

API Usage

var handler = new HttpClientHandler
{
    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Zstandard
};

Alternative Designs

Zstd instead of Zstandard?

The name used for encoding headers is zstd and the media type is application/zstd, while the proposed compression APIs are using Zstandard.

Similar with Brotli where br is used for headers, but we call the APIs Brotli.

Risks

Requires shipping Zstd in System.Compression.Native.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions