snoyberg / http-client

An HTTP client engine, intended as a base layer for more user-friendly packages.
274 stars 193 forks source link

Multipart file parts without Content-Type #535

Open moll opened 1 month ago

moll commented 1 month ago

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!

snoyberg commented 1 month ago

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

moll commented 1 month ago

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.

snoyberg commented 1 month ago

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