-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
CURLOPT_POST issue after CURLOPT_UPLOAD #9507
Comments
I believe this may be the issue. CURLOPT_POST does not touch the upload flag: Lines 693 to 703 in ddda4fd
But when the upload flag is set the method is changed to PUT: Lines 2101 to 2108 in c616259
|
Thanks for the excellent reproducer. I successfully converted it into a curl test case and could reproduce the problem and then verify my fix, all based on your work here. |
Thanks! I'm thrilled that I could help! As I see (for HTTP) CURLOPT_HTTPGET, CURLOPT_NOBODY, CURLOPT_UPLOAD, and CURLOPT_POST as mutually exclusive (I'm not certain about CURLOPT_CUSTOMREQUEST), I do have a question and two suggestions:
|
On Thu, Sep 15, 2022 at 07:05:06AM -0700, RobBotic1 wrote:
As I see (for HTTP) CURLOPT_HTTPGET, CURLOPT_NOBODY, CURLOPT_UPLOAD, and
CURLOPT_POST as mutually exclusive
Are you sure about this? Why can't one do a CURLOPT_UPLOAD with CURLOPT_NOBODY? CURLOPT_NOBODY refers to the body of the response, not the request, after all.
|
I was looking at this as CURLOPT_NOBODY essentially maps to HTTP HEAD, per curl/docs/libcurl/opts/CURLOPT_NOBODY.3 Lines 36 to 38 in c04c78a
and curl/docs/libcurl/opts/CURLOPT_NOBODY.3 Lines 48 to 50 in c04c78a
I'd also note that CURLOPT_POST already disables CURLOPT_NOBODY, so this would be consistent for a PUT (CURLOPT_UPLOAD). That said, a mechanism to request no response body would be useful. |
Ah, right—that's a big difference between HTTP and most other protocols.
|
UPLOAD over HTTP means PUT, there is no way to ask for a PUT without a body in HTTP so curl cannot do that on itself. If you want to stop reading at some point, you do that by returning an error from the write callback. |
I did this
The following snippet recreates the behavior with minimal error handling for readability:
I expected the following
I expected using CURLOPT_POST to cause an HTTP POST. However, it appears that the previously set CURLOPT_UPLOAD overrides this behavior and causes an HTTP PUT to occur. I would expect CURLOPT_POST to unset HTTP PUT as well as HTTP GET and HTTP HEAD (much like setting CURLOPT_HTTPGET overrides previously set CURLOPT_NOBODY and CURLOPT_UPLOAD).
curl/libcurl version
curl 7.85.0 (aarch64-apple-darwin21.6.0) libcurl/7.85.0 (SecureTransport) OpenSSL/1.1.1q zlib/1.2.11 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.3 libssh2/1.10.0 nghttp2/1.49.0 librtmp/2.3
Release-Date: 2022-08-31
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
operating system
macOS Monterey
The text was updated successfully, but these errors were encountered: