A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. libcurl offers a myriad of powerful features
Go to file
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
.circleci CI: enable parallel make in more builds 2023-06-24 14:40:39 -07:00
.github wolfssl: support loading system CA certificates 2023-07-31 08:27:50 +02:00
.reuse mlc_config.json: remove this linkcheck CI job config file 2023-05-15 13:23:54 +02:00
CMake nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
docs tool: add "variable" support 2023-07-31 11:51:34 +02:00
include RELEASE-NOTES: synced 2023-07-27 23:58:57 +02:00
lib tool: add "variable" support 2023-07-31 11:51:34 +02:00
LICENSES copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
m4 nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
packages nss: remove support for this TLS library 2023-07-29 23:44:28 +02:00
plan9 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
projects tool: add "variable" support 2023-07-31 11:51:34 +02:00
scripts checksrc: quote the file name to work with "funny" letters 2023-07-13 14:25:18 +02:00
src tool: add "variable" support 2023-07-31 11:51:34 +02:00
tests tool: add "variable" support 2023-07-31 11:51:34 +02:00
winbuild tool: add "variable" support 2023-07-31 11:51:34 +02:00
.azure-pipelines.yml CI: don't run CI jobs if only another CI was changed 2023-04-24 20:46:09 -07:00
.cirrus.yml CI: enable parallel make in more builds 2023-06-24 14:40:39 -07:00
.dcignore copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
.dir-locals.el copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
.git-blame-ignore-revs copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
.gitattributes copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
.gitignore copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
.mailmap mailmap: add Derzsi Dániel 2023-07-31 08:29:16 +02:00
acinclude.m4 timeval: use CLOCK_MONOTONIC_RAW if available 2023-06-13 00:02:32 +02:00
appveyor.yml CI: make Appveyor job names unique 2023-06-28 01:07:21 -07:00
buildconf copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
buildconf.bat copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
CHANGES curl.se: new home 2020-11-04 23:59:47 +01:00
CMakeLists.txt configure, cmake, lib: more form api deprecation 2023-07-31 08:31:38 +02:00
configure.ac configure, cmake, lib: more form api deprecation 2023-07-31 08:31:38 +02:00
COPYING copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-config.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
GIT-INFO GIT-INFO: add --with-openssl 2023-05-14 23:22:23 +02:00
libcurl.pc.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
MacOSX-Framework copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
Makefile.am nss: delete more NSS references 2023-07-30 21:55:29 +00:00
Makefile.dist copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
maketgz copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
README docs: minor grammar fixes 2022-09-29 10:44:12 +02:00
README.md README.md: updated link to opencollective 2023-06-02 11:29:15 +02:00
RELEASE-NOTES RELEASE-NOTES: synced 2023-07-27 23:58:57 +02:00
SECURITY.md copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00

curl logo

Curl is a command-line tool for transferring data specified with URL syntax. Find out how to use curl by reading the curl.1 man page or the MANUAL document. Find out how to install Curl by reading the INSTALL document.

libcurl is the library curl is using to do its job. It is readily available to be used by your software. Read the libcurl.3 man page to learn how.

You can find answers to the most frequent questions we get in the FAQ document.

Study the COPYING file for distribution terms.

Contact

If you have problems, questions, ideas or suggestions, please contact us by posting to a suitable mailing list.

All contributors to the project are listed in the THANKS document.

Commercial support

For commercial support, maybe private and dedicated help with your problems or applications using (lib)curl visit the support page.

Website

Visit the curl website for the latest news and downloads.

Git

To download the latest source from the Git server, do this:

git clone https://github.com/curl/curl.git

(you will get a directory named curl created, filled with the source code)

Security problems

Report suspected security problems via our HackerOne page and not in public.

Notice

Curl contains pieces of source code that is Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan. This notice is included here to comply with the distribution terms.

Backers

Thank you to all our backers! 🙏 Become a backer.

Sponsors

Support this project by becoming a sponsor.