When downloading a file with HttpClient, I'm downloading first the headers and then the content. When headers are downloaded, I can see Headers collection on the Content property of HttpResponseMessage, but when accessing it through ContentDisposition on Headers, get null
Why this is happening? Fiddler shows headers are fine...
Code:
var responseMessage = await httpClient.GetAsync(uri,
HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(continueOnCapturedContext: false);
Update 1
It looks like this class is following Content-Disposition implementation outlined in RFC 2616 and fails to handle Content-Disposition implementation update RFC 6266. RFC 2616 defines filename
parameter value to be a quoted-string, where update RFC 6266 just states it should be value.
RFC 2616 Grammar
content-disposition = "Content-Disposition" ":"
disposition-type *( ";" disposition-parm )
disposition-type = "attachment" | disp-extension-token
disposition-parm = filename-parm | disp-extension-parm
filename-parm = "filename" "=" quoted-string
disp-extension-token = token
disp-extension-parm = token "=" ( token | quoted-string )
RFC 6266 Grammar
content-disposition = "Content-Disposition" ":"
disposition-type *( ";" disposition-parm )
disposition-type = "inline" | "attachment" | disp-ext-type
; case-insensitive
disp-ext-type = token
disposition-parm = filename-parm | disp-ext-parm
filename-parm = "filename" "=" value
| "filename*" "=" ext-value
disp-ext-parm = token "=" value
| ext-token "=" ext-value
ext-token = <the characters in token, followed by "*">
where ext-value = <ext-value, defined in [RFC5987], Section 3.2>
Examples
Working case
Failing case
Update 2
Opened a ticket with MS connect.
Update 3
Microsoft has acknowledged that this is a bug and will fix it.