• Home
  • Raw
  • Download

Lines Matching full:curl

4 SPDX-License-Identifier: curl
7 # The Art Of Scripting HTTP Requests Using Curl
18 Curl is a command line tool for doing all sorts of URL manipulations and
21 invoke `curl --help` or `curl --manual` to get basic information about it.
23 Curl is not written to do everything for you. It makes the requests, it gets
39 The client, curl, sends an HTTP request. The request contains a method (like
47 Using curl's option [`--verbose`](https://curl.se/docs/manpage.html#-v) (`-v`
48 as a short option) displays what kind of commands curl sends to the server,
52 understand the curl<->server interaction.
55 [`--trace`](https://curl.se/docs/manpage.html#-trace) and
56 [`--trace-ascii`](https://curl.se/docs/manpage.html#--trace-ascii)
57 offer even more details as they show **everything** curl sends and
60 curl --trace-ascii debugdump.txt http://www.example.com/
67 [`--trace-time`](https://curl.se/docs/manpage.html#--trace-time) option is
70 curl --trace-ascii d.txt --trace-time http://example.com/
77 [`--trace-ids`](https://curl.se/docs/manpage.html#--trace-ids) option is what
81 curl --trace-ascii d.txt --trace-ids http://example.com/
85 By default curl sends the response to stdout. You need to redirect it
94 https://curl.se or https://example.com a million times. RFC 3986 is the
100 address and that is what curl communicates with. Alternatively you specify
104 IP address for a hostname than what would otherwise be used, by using curl's
105 [`--resolve`](https://curl.se/docs/manpage.html#--resolve) option:
107 curl --resolve www.example.org:80:127.0.0.1 http://www.example.org/
111 Each protocol curl supports operates on a default port number, be it over TCP
118 curl http://www.example.org:1234/
122 need to specify that proxy's port number separately from what curl needs to
125 curl --proxy http://proxy.example.org:4321 http://remote.example.org/
136 curl http://user:password@example.org/
140 curl -u user:password http://example.org/
161 curl https://curl.se
167 use curl's [`--include`](https://curl.se/docs/manpage.html#-i) (`-i`)
173 [`--head`](https://curl.se/docs/manpage.html#-I) (`-I`) option which makes
174 curl issue a HEAD request. In some special cases servers deny the HEAD method
184 A single curl command line may involve one or many URLs. The most common case
191 curl http://url1.example.com http://url2.example.com
193 If you use [`--data`](https://curl.se/docs/manpage.html#-d) to POST to
199 curl --data name=curl http://url1.example.com http://url2.example.com
206 [`--next`](https://curl.se/docs/manpage.html#-:) option. It is basically a
211 When curl reaches the `--next` on the command line, it resets the method and
217 curl -I http://example.com --next http://example.com
221 curl -d score=10 http://example.com/post.cgi --next http://example.com/results.html
261 To make curl do the GET form post for you, just enter the expected created
264 curl "http://www.example.com/when/junk.cgi?birthyear=1905&press=OK"
287 And to use curl to post this form with the same data filled in as before, we
290 curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when/junk.cgi
295 The data you send to the server MUST already be properly encoded, curl does
300 Recent curl versions can in fact url-encode POST data for you, like this:
302 curl --data-urlencode "name=I am Daniel" http://www.example.com
304 If you repeat `--data` several times on the command line, curl concatenates
324 To post to a form like this with curl, you enter a command line like:
326 curl --form upload=@localfilename --form press=OK [URL]
346 To POST this with curl, you do not have to think about if the fields are
347 hidden or not. To curl they are all the same:
349 curl --data "birthyear=1905&press=OK&person=daniel" [URL]
353 When you are about to fill in a form and send it to a server by using curl
372 Put a file to an HTTP server with curl:
374 curl --upload-file uploadfile http://www.example.com/receive.cgi
382 doing. The Basic authentication used in HTTP (which is the type curl uses by
387 To tell curl to use a user and password for authentication:
389 curl --user name:password http://www.example.com
395 [`--ntlm`](https://curl.se/docs/manpage.html#--ntlm),
396 [`--digest`](https://curl.se/docs/manpage.html#--digest),
397 [`--negotiate`](https://curl.se/docs/manpage.html#--negotiate) or even
398 [`--anyauth`](https://curl.se/docs/manpage.html#--anyauth) might be
406 the Internet. To specify those with curl, run something like:
408 curl --proxy-user proxyuser:proxypassword curl.se
411 use [`--proxy-ntlm`](https://curl.se/docs/manpage.html#--proxy-ntlm), if
413 [`--proxy-digest`](https://curl.se/docs/manpage.html#--proxy-digest).
416 part, curl prompts for the password interactively.
438 do it. Using curl, you can put anything you want in the referer-field and
441 Use curl to set the referer field with:
443 curl --referer http://www.example.come http://www.example.com
454 At times, you may learn that getting a page with curl does not return the
459 To make curl look like Internet Explorer 5 on a Windows 2000 box:
461 curl --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" [URL]
465 curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
476 Curl does not follow `Location:` headers by default, but simply displays such
480 To tell curl to follow a Location:
482 curl --location http://www.example.com
484 If you use curl to POST to a site that immediately redirects you to another
485 page, you can safely use [`--location`](https://curl.se/docs/manpage.html#-L)
486 (`-L`) and `--data`/`--form` together. Curl only uses POST in the first
491 Browsers typically support at least two other ways of redirects that curl
511 into a single logical session. To be able to use curl in such occasions, we
518 curl is to add them on the command line like:
520 curl --cookie "name=Daniel" http://www.example.com
522 Cookies are sent as common HTTP headers. This is practical as it allows curl
523 to record cookies simply by recording headers. Record cookies with curl by
524 using the [`--dump-header`](https://curl.se/docs/manpage.html#-D) (`-D`)
527 curl --dump-header headers_and_cookies http://www.example.com
530 [`--cookie-jar`](https://curl.se/docs/manpage.html#-c) option described
533 Curl has a full blown cookie parsing engine built-in that comes in use if you
537 you run curl like:
539 curl --cookie stored_cookies_in_file http://www.example.com
541 Curl's "cookie engine" gets enabled when you use the
542 [`--cookie`](https://curl.se/docs/manpage.html#-b) option. If you only
543 want curl to understand received cookies, use `--cookie` with a file that
544 does not exist. Example, if you want to let curl understand cookies from a
548 curl --cookie nada --location http://www.example.com
550 Curl has the ability to read and write cookie files that use the same file
554 and by using the `--cookie-jar` (`-c`) option you make curl write a new
557 curl --cookie cookies.txt --cookie-jar newcookies.txt \
572 Curl supports encrypted fetches when built to use a TLS library and it can be
573 built to use one out of a fairly large set of libraries - `curl -V` shows
574 which one your curl was built to use (if any!). To get a page from an HTTPS
575 server, simply run curl like:
577 curl https://secure.example.com
582 you claim to be, as an addition to normal passwords. Curl supports client-
584 need to enter before the certificate can be used by curl. The pass phrase
586 curl queries for it. Use a certificate with curl on an HTTPS server like:
588 curl --cert mycert.pem https://secure.example.com
590 curl also tries to verify that the server is who it claims to be, by
592 Failing the verification causes curl to deny the connection. You must then
593 use [`--insecure`](https://curl.se/docs/manpage.html#-k) (`-k`) in case you
594 want to tell curl to ignore that the server cannot be verified.
597 the [`SSLCERTS` document](https://curl.se/docs/sslcerts.html).
600 curl to use that to verify the server's certificate:
602 curl --cacert ca-bundle.pem https://example.com/
608 Doing fancy stuff, you may need to add or change elements of a single curl
615 curl --data "<xml>" --header "Content-Type: text/xml" \
621 curl --header "Host:" http://www.example.com
626 curl --header "Destination: http://nowhere" http://example.com
630 It should be noted that curl selects which methods to use on its own
632 so on. If you use the [`--request`](https://curl.se/docs/manpage.html#-X) /
633 `-X` option you can change the method keyword curl selects, but you do not
634 modify curl's behavior. This means that if you for example use -d "data" to
635 do a POST, you can modify the method to a `PROPFIND` with `-X` and curl still
639 curl -X POST http://example.org/
641 curl however still acts as if it sent a GET so it does not send any request
650 login forms work and how to login to them using curl.
653 most certainly need to script things and do multiple curl invokes etc.
679 Many times when you run curl on a site, you notice that the site does not
680 seem to respond the same way to your curl requests as it does to your
683 Then you need to start making your curl requests more similar to your
692 - Set user-agent (with [`-A`](https://curl.se/docs/manpage.html#-A)) to
695 - Set referer (with [`-E`](https://curl.se/docs/manpage.html#-E)) like