Skip to content

Explicit content-type: multipart/form-data leads to unexpected content-disposition:attachment in the http body #5256

@thanhchungbtc

Description

@thanhchungbtc

I did this

curl -X POST -F 'name=foo' -H 'Content-type: multipart/form-data; charset=utf-8' third_party_url

I expected the following

The problem was I am using the above command to send an HTTP request to a third-party. Things work fine until I upgraded curl to the latest version.
After debugging HTTP request, I found that before curl 7.6x, the request body has sent as ofContent-Disposition: form-data

--------------------------3edca486ca6ca909
Content-Disposition: form-data; name="name"

foo
--------------------------3edca486ca6ca909--

while in version 7.6x, it was attachment

--------------------------bf7e9dd83bb9d22e
Content-Disposition: attachment; name="name"

foo
--------------------------bf7e9dd83bb9d22e--

If I omit the Content-type header, it goes well (both result in Content-Disposition: form-data) but I also lose the ability to set the charset header which is critical for me.

curl/libcurl version

curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets

operating system

This problem happens in my AWS EC2 instance but since I can reproduce it in my local machine, I do think it is related to 7.6x version

Darwin myname-MacBook-Pro.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions