I have a .NET 7 client that targets a third-party API:
var handler = new HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.All
};
var httpClient = new HttpClient(handler)
{
BaseAddress = new Uri(baseUrl)
};
client = new MyClient(httpClient, token);
I've tried the above, but it doesn't work.
The API I am targeting with the typed client sends a response that contains a zipped file that contains multiple XML files. Is it possible to configure HttpClient to decompress this file, and access all the decompressed files, and not just the first one?
CodePudding user response:
From the HttpClientHandler.AutomaticDecompression
docs:
Gets or sets the type of decompression method used by the handler for automatic decompression of the HTTP content response.
From the HttpClient
standpoint (based on the description you gave) the content is the file itself so the client can take care only of extra compression which could be applied to it during the sending, if the file is an archive you will need to decompress it "manually" (for example via ZipArchive
).