3 ms·
do not use -X without having read the manual, it can break redirects and other things. from the curl(1) manpage: -X, --request <command>
by ta0967 10y ago
do not use -X without having read the manual, it can break redirects and other things.
from the curl(1) manpage:
-X, --request <command>
(...)
Normally you don't need this option. All sorts of GET, HEAD, POST and PUT requests are rather
invoked by using dedicated command line options.
This option only changes the actual word used in the HTTP request, it does not alter the way
curl behaves. So for example if you want to make a proper HEAD request, using -X HEAD will not
suffice. You need to use the -I, --head option.
The method string you set with -X will be used for all requests, which if you for example use
-L, --location may cause unintended side-effects when curl doesn't change request method
according to the HTTP 30x response codes - and similar.
PUT is indicated by using -T / --upload-file, POST by -d / --data or any --data-foo option (eg. --data-raw).
DELETE is the only HTTP method in the parent list that needs -X to be used.
- xaduha 10y agoThe point is to have the ability to pipe to curl, will -T / --upload-file allow that? For now I'm happy with how it worked.
- ta0967 10y agothe manpage is very explicit about that: Use the file name "-" (a single dash) to use stdin instead of a given file. Alternately, the file name "." (a single period) may be specified instead of "-" to use stdin in non-blocking mode to allow reading server output while stdin is being uploaded.