Add support for command line variables. Set variables with --variable
name=content or --variable name@file (where "file" can be stdin if set
to a single dash (-)).
Variable content is expanded in option parameters using "{{name}}"
(without the quotes) if the option name is prefixed with
"--expand-". This gets the contents of the variable "name" inserted, or
a blank if the name does not exist as a variable. Insert "{{" verbatim
in the string by prefixing it with a backslash, like "\\{{".
Import an environment variable with --variable %name. It makes curl exit
with an error if the environment variable is not set. It can also rather
get a default value if the variable does not exist, using =content or
@file like shown above.
Example: get the USER environment variable into the URL:
--variable %USER
--expand-url = "https://example.com/api/{{USER}}/method"
When expanding variables, curl supports a set of functions that can make
the variable contents more convenient to use. It can trim leading and
trailing white space with "trim", output the contents as a JSON quoted
string with "json", URL encode it with "url" and base 64 encode it with
"b64". To apply functions to a variable expansion, add them colon
separated to the right side of the variable. They are then performed in
a left to right order.
Example: get the contents of a file called $HOME/.secret into a variable
called "fix". Make sure that the content is trimmed and percent-encoded
sent as POST data:
--variable %HOME=/home/default
--expand-variable fix@{{HOME}}/.secret
--expand-data "{{fix:trim:url}}"
https://example.com/
Documented. Many new test cases.
Co-brainstormed-by: Emanuele Torre
Assisted-by: Jat Satiro
Closes #11346
|
||
|---|---|---|
| .. | ||
| cmdline-opts | ||
| examples | ||
| libcurl | ||
| .gitignore | ||
| ALTSVC.md | ||
| BINDINGS.md | ||
| BUFQ.md | ||
| BUFREF.md | ||
| BUG-BOUNTY.md | ||
| BUGS.md | ||
| CHECKSRC.md | ||
| CIPHERS.md | ||
| CMakeLists.txt | ||
| CODE_OF_CONDUCT.md | ||
| CODE_REVIEW.md | ||
| CODE_STYLE.md | ||
| CONNECTION-FILTERS.md | ||
| CONTRIBUTE.md | ||
| curl-config.1 | ||
| CURL-DISABLE.md | ||
| DEPRECATE.md | ||
| DYNBUF.md | ||
| EARLY-RELEASE.md | ||
| EXPERIMENTAL.md | ||
| FAQ | ||
| FEATURES.md | ||
| GOVERNANCE.md | ||
| HELP-US.md | ||
| HISTORY.md | ||
| HSTS.md | ||
| HTTP2.md | ||
| HTTP3.md | ||
| HTTP-COOKIES.md | ||
| HYPER.md | ||
| INSTALL | ||
| INSTALL.cmake | ||
| INSTALL.md | ||
| INTERNALS.md | ||
| KNOWN_BUGS | ||
| MAIL-ETIQUETTE | ||
| Makefile.am | ||
| MANUAL.md | ||
| mk-ca-bundle.1 | ||
| MQTT.md | ||
| NEW-PROTOCOL.md | ||
| options-in-versions | ||
| PARALLEL-TRANSFERS.md | ||
| README.md | ||
| RELEASE-PROCEDURE.md | ||
| ROADMAP.md | ||
| RUSTLS.md | ||
| SECURITY-ADVISORY.md | ||
| SECURITY-PROCESS.md | ||
| SSL-PROBLEMS.md | ||
| SSLCERTS.md | ||
| THANKS | ||
| THANKS-filter | ||
| TheArtOfHttpScripting.md | ||
| TODO | ||
| URL-SYNTAX.md | ||
| VERSIONS.md | ||
| WEBSOCKET.md | ||
Documentation
you will find a mix of various documentation in this directory and subdirectories, using several different formats. Some of them are not ideal for reading directly in your browser.
If you would rather see the rendered version of the documentation, check out the curl website's documentation section for general curl stuff or the libcurl section for libcurl related documentation.