Handling gzip Responses with .NET's HttpClient

Recently, I was working on a project that required me to make HTTP requests to a service that returned gzip-compressed responses for some endpoints. I was using .NET's HttpClient class to make the requests, and was surprised that gzip responses were not automatically decompressed. I had to add a few lines of code to enable automatic handling of the decompression.

using System.Net;

var httpClientHandler = new HttpClientHandler
{
    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
};

var httpClient = new HttpClient(httpClientHandler);