'Content-Disposition empty when using umlauts

I need to double check something. I am using an API to retrieve stored documents from a server. I do it like this

var message = new HttpRequestMessage(HttpMethod.Get, url);
var response = await this.Client.SendAsync(message);

if (response.StatusCode == HttpStatusCode.OK)
{
    byte[] responseBody = await response.Content.ReadAsByteArrayAsync();
    string filename = response.Content.Headers.ContentDisposition.FileName;
}
else
{
    // ...
}

When I download a document like this, then the ContentDisposition is not null and contains the filename in ContentDisposition.FileName

Now here's the thing: If the document contained umlauts when they were uploaded and I download the same document via API again, watching at response.Content.Headers shows the actual content disposition, but the ContentDisposition property itself is null.

ContentDisposition with filename containing umlauts

Sure, I could probably parse it right from Headers with Headers.TryGetValues("Content-Disposition", out _) but there has to be a reason for that. I'm not quite sure if that's common practice or an API bug (or even C# bug). Do you have any clues?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source