curl/docs
Daniel Stenberg 2e160c9c65
tool: add "variable" support
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
2023-07-31 11:51:34 +02:00
..
cmdline-opts tool: add "variable" support 2023-07-31 11:51:34 +02:00
examples example/maxconnects: set maxconnect example 2023-07-11 20:13:25 +02:00
libcurl wolfssl: support loading system CA certificates 2023-07-31 08:27:50 +02:00
.gitignore copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
ALTSVC.md docs: minor grammar fixes 2022-09-29 10:44:12 +02:00
BINDINGS.md BINDINGS: add Fortran binding 2023-02-22 16:45:32 +01:00
BUFQ.md docs: add documentation for bufq 2023-03-30 17:13:53 +02:00
BUFREF.md docs: spellfixes 2022-09-21 15:20:08 +02:00
BUG-BOUNTY.md BUG-BOUNTY.md: mention the audit exception 2022-05-19 11:14:54 +02:00
BUGS.md docs: minor grammar fixes 2022-09-29 10:44:12 +02:00
CHECKSRC.md docs: spellfixes 2022-09-21 15:20:08 +02:00
CIPHERS.md nss: delete more NSS references 2023-07-30 21:55:29 +00:00
CMakeLists.txt copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
CODE_OF_CONDUCT.md docs: Update to secure URL versions 2017-09-04 14:08:54 +00:00
CODE_REVIEW.md docs: spellfixes 2022-09-21 15:20:08 +02:00
CODE_STYLE.md docs: minor polish 2023-04-27 13:23:01 +02:00
CONNECTION-FILTERS.md docs: minor polish 2023-04-27 13:23:01 +02:00
CONTRIBUTE.md CONTRIBUTE: drop mention of copyright year ranges 2023-07-23 23:47:35 +02:00
curl-config.1 man pages: simplify the .TH sections 2023-04-26 10:17:13 +02:00
CURL-DISABLE.md configure, cmake, lib: more form api deprecation 2023-07-31 08:31:38 +02:00
DEPRECATE.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
DYNBUF.md DYNBUF.md: note Curl_dyn_add* calls Curl_dyn_free on failure 2023-03-01 04:18:15 -05:00
EARLY-RELEASE.md RELEASE-PROCEDURE: update to new schedule 2023-03-26 17:39:43 +02:00
EXPERIMENTAL.md openssl: Don't ignore CA paths when using Windows CA store (redux) 2023-01-17 03:32:58 -05:00
FAQ nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
FEATURES.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
GOVERNANCE.md misc: typo and grammar fixes 2022-10-27 10:01:30 +02:00
HELP-US.md docs: add link to GitHub Discussions 2023-01-02 00:26:37 +01:00
HISTORY.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
HSTS.md docs: spellfixes 2022-09-21 15:20:08 +02:00
HTTP2.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
HTTP3.md HTTP3.md: ngtcp2 updated to v0.17.0 and nghttp3 to v0.13.0 2023-07-13 08:56:41 +02:00
HTTP-COOKIES.md docs: use a space after RFC when spelling out RFC numbers 2023-07-09 19:13:33 +02:00
HYPER.md misc: typo and grammar fixes 2022-10-27 10:01:30 +02:00
INSTALL INSTALL: converted to markdown => INSTALL.md 2016-10-21 15:57:29 +02:00
INSTALL.cmake nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
INSTALL.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
INTERNALS.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
KNOWN_BUGS KNOWN_BUGS: cygwin: make install installs curl-config.1 twice 2023-07-31 08:55:26 +02:00
MAIL-ETIQUETTE docs: remove him/her/he/she from documentation 2022-07-27 13:52:53 +02:00
Makefile.am docs/SECURITY-ADVISORY.md: how to write a curl security advisory 2023-05-08 09:40:29 +02:00
MANUAL.md MANUAL.md: add dict example for looking up a single definition 2023-05-05 23:49:25 +02:00
mk-ca-bundle.1 man pages: simplify the .TH sections 2023-04-26 10:17:13 +02:00
MQTT.md docs: reduce/avoid English contractions 2021-11-07 23:16:27 +01:00
NEW-PROTOCOL.md docs: minor grammar fixes 2022-09-29 10:44:12 +02:00
options-in-versions tool: add "variable" support 2023-07-31 11:51:34 +02:00
PARALLEL-TRANSFERS.md PARALLEL-TRANSFERS.md: not "early days" for this anymore 2023-02-27 20:08:54 +01:00
README.md docs: reduce/avoid English contractions 2021-11-07 23:16:27 +01:00
RELEASE-PROCEDURE.md RELEASE-PROCEDURE.md: adjust the release dates 2023-07-18 12:06:50 +02:00
ROADMAP.md spellcheck.words: remove 'github' as an accepted word 2022-10-27 15:53:11 +02:00
RUSTLS.md rustls: update rustls-ffi 0.10.0 2023-07-22 23:40:44 +02:00
SECURITY-ADVISORY.md docs/SECURITY-ADVISORY.md: how to write a curl security advisory 2023-05-08 09:40:29 +02:00
SECURITY-PROCESS.md docs/SECURITY-PROCESS.md: link to example of previous critical flaw 2023-06-02 18:05:22 +02:00
SSL-PROBLEMS.md misc: typo and grammar fixes 2022-10-27 10:01:30 +02:00
SSLCERTS.md nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
THANKS THANKS: add contributors from 8.2.1 2023-07-26 08:10:40 +02:00
THANKS-filter THANKS-filter: strip out "GitHub" 2023-07-19 08:12:46 +02:00
TheArtOfHttpScripting.md docs: use a space after RFC when spelling out RFC numbers 2023-07-09 19:13:33 +02:00
TODO TODO: Obey Retry-After in redirects 2023-07-21 13:54:13 +02:00
URL-SYNTAX.md docs: use a space after RFC when spelling out RFC numbers 2023-07-09 19:13:33 +02:00
VERSIONS.md docs: spellfixes 2022-09-21 15:20:08 +02:00
WEBSOCKET.md WEBSOCKET.md: typo 2023-02-10 10:28:40 +01:00

curl logo

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.