Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixing --data and --upload-file sets content-length from --data and sends data from --upload-file #8704

Closed
verhovsky opened this issue Apr 13, 2022 · 2 comments
Assignees
Labels

Comments

@verhovsky
Copy link
Contributor

I did this

cd /tmp
echo some very long text much longer blah blah > my_file.txt
curl -vvv --data 'short message' --upload-file my_file.txt example.com

I expected the following

An error message or for --data to win or --upload-file to win.

Instead, I see this

[...]
> Content-Length: 13
> Expect: 100-continue
[...]

Content-Length: 13 comes from --data, but the actual data being sent is the data in --upload-file.

I don't blame curl for doing something non-sensical here because passing both of these arguments is non-sensical, but I think it would be better for one option to win completely.

curl/libcurl version

curl 7.79.1 (x86_64-apple-darwin21.0) libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.5 zlib/1.2.11 nghttp2/1.45.1
Release-Date: 2021-09-22
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets

operating system

macOS 12.3.1

@danielgustafsson
Copy link
Member

As per the documentation, --data overrides --upload-file so it seems the data from --upload-file should be discarded here.

@verhovsky verhovsky changed the title mixing --data and --upload-file for HTTP sets content-length from --data and sends data from --upload-file mixing --data and --upload-file sets content-length from --data and sends data from --upload-file Apr 13, 2022
@bagder
Copy link
Member

bagder commented Apr 16, 2022

The phrasing in the man page I think is unfortunate. "This option overrides -F, --form and -I, --head and -T, --upload-file."

That line is generated by the keyword Mutexed: form head upload-file in data.d but I don't think we should say "overrides" just because the option is mutexed as it isn't true in all cases. We should probably say something more in line with "this option can (should?) not be used together with ..."

bagder added a commit that referenced this issue Apr 16, 2022
As one implies PUT and the other POST, both cannot be used
simultaneously.

Add test 378 to verify.

Fixes #8704
Reported-by: Boris Verkhovskiy
bagder added a commit that referenced this issue Apr 16, 2022
Instead of saying "This option overrides NNN", now say "This option is
mutually exclusive to NNN" in the generated man page ouput, as the
option does not in all cases actually override the others but they are
always mutually exclusive.

Ref: #8704
@bagder bagder self-assigned this Apr 16, 2022
@bagder bagder closed this as completed in 01a1697 Apr 17, 2022
bagder added a commit that referenced this issue Apr 17, 2022
Instead of saying "This option overrides NNN", now say "This option is
mutually exclusive to NNN" in the generated man page ouput, as the
option does not in all cases actually override the others but they are
always mutually exclusive.

Ref: #8704
Closes #8716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants