http-client icon indicating copy to clipboard operation
http-client copied to clipboard

Multipart file parts without Content-Type

Open moll opened this issue 1 year ago • 3 comments

Hey,

Thanks for your continued maintenance of HttpClient!

I've been using the Multipart functionality in Network.HTTP.Client.MultipartFormData and noticed it insists on setting the Content-Type of a file part, derived from its file extension. Would you consider disabling that or giving a way to unset it? I'd like to use custom content-types or even leave them out.

Perhaps if the implementation set a default header in the Part constructor instead of a separate Part field, it'd be more general to also overwrite via a hypothetical modifyHeaders accessor. Seems a tad odd for that header to be special-cased in the first place.

Thanks!

moll avatar May 17 '24 00:05 moll

I've never tried this, but it looks like partContentType can be set to Nothing.

snoyberg avatar May 19 '24 05:05 snoyberg

If I'm not mistaken, that won't be possible if the constructor is not exported in https://github.com/snoyberg/http-client/blob/6f742e857a91b37f9d1618a30510fc4f97989342/http-client/Network/HTTP/Client/MultipartFormData.hs. I think I saw in a mention of making the constructor private in a pre 2015 issue somewhere to permit easier implementation changes without affecting the API.

moll avatar May 19 '24 08:05 moll

Please see https://www.yesodweb.com/book/settings-types, it’s still possible to set these fields.

snoyberg avatar May 19 '24 08:05 snoyberg