• Home
  • Raw
  • Download

Lines Matching full:curl

1 # The Art Of Scripting HTTP Requests Using Curl
12 Curl is a command line tool for doing all sorts of URL manipulations and
15 how to invoke `curl --help` or `curl --manual` to get basic information about
18 Curl is not written to do everything for you. It makes the requests, it gets
34 The client, curl, sends an HTTP request. The request contains a method (like
42 Using curl's option [`--verbose`](https://curl.se/docs/manpage.html#-v)
43 (`-v` as a short option) will display what kind of commands curl sends to the
47 understand the curl<->server interaction.
50 [`--trace`](https://curl.se/docs/manpage.html#-trace) and
51 [`--trace-ascii`](https://curl.se/docs/manpage.html#--trace-ascii)
52 offer even more details as they show **everything** curl sends and
55 curl --trace-ascii debugdump.txt http://www.example.com/
62 [`--trace-time`](https://curl.se/docs/manpage.html#--trace-time) option
65 curl --trace-ascii d.txt --trace-time http://example.com/
72 [`--trace-ids`](https://curl.se/docs/manpage.html#--trace-ids) option
76 curl --trace-ascii d.txt --trace-ids http://example.com/
80 By default curl sends the response to stdout. You need to redirect it
89 https://curl.se or https://example.com a million times. RFC 3986 is the
95 address and that is what curl will communicate with. Alternatively you specify
99 IP address for a host name than what would otherwise be used, by using curl's
100 [`--resolve`](https://curl.se/docs/manpage.html#--resolve) option:
102 curl --resolve www.example.org:80:127.0.0.1 http://www.example.org/
106 Each protocol curl supports operates on a default port number, be it over TCP
113 curl http://www.example.org:1234/
117 need to specify that proxy's port number separately from what curl needs to
120 curl --proxy http://proxy.example.org:4321 http://remote.example.org/
131 curl http://user:password@example.org/
135 curl -u user:password http://example.org/
156 curl https://curl.se
162 use curl's [`--include`](https://curl.se/docs/manpage.html#-i) (`-i`)
168 [`--head`](https://curl.se/docs/manpage.html#-I) (`-I`) option which
169 will make curl issue a HEAD request. In some special cases servers deny the
179 A single curl command line may involve one or many URLs. The most common case
186 curl http://url1.example.com http://url2.example.com
188 If you use [`--data`](https://curl.se/docs/manpage.html#-d) to POST to
194 curl --data name=curl http://url1.example.com http://url2.example.com
201 [`--next`](https://curl.se/docs/manpage.html#-:) option. It is basically
206 When curl reaches the `--next` on the command line, it will sort of reset the
212 curl -I http://example.com --next http://example.com
216 curl -d score=10 http://example.com/post.cgi --next http://example.com/results.html
256 To make curl do the GET form post for you, just enter the expected created
259 curl "http://www.example.com/when/junk.cgi?birthyear=1905&press=OK"
282 And to use curl to post this form with the same data filled in as before, we
285 curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when/junk.cgi
290 The data you send to the server MUST already be properly encoded, curl will
295 Recent curl versions can in fact url-encode POST data for you, like this:
297 curl --data-urlencode "name=I am Daniel" http://www.example.com
299 If you repeat `--data` several times on the command line, curl will
322 To post to a form like this with curl, you enter a command line like:
324 curl --form upload=@localfilename --form press=OK [URL]
344 To POST this with curl, you will not have to think about if the fields are
345 hidden or not. To curl they are all the same:
347 curl --data "birthyear=1905&press=OK&person=daniel" [URL]
351 When you are about to fill in a form and send it to a server by using curl
370 Put a file to an HTTP server with curl:
372 curl --upload-file uploadfile http://www.example.com/receive.cgi
380 doing. The Basic authentication used in HTTP (which is the type curl uses by
385 To tell curl to use a user and password for authentication:
387 curl --user name:password http://www.example.com
393 [`--ntlm`](https://curl.se/docs/manpage.html#--ntlm),
394 [`--digest`](https://curl.se/docs/manpage.html#--digest),
395 [`--negotiate`](https://curl.se/docs/manpage.html#--negotiate) or even
396 [`--anyauth`](https://curl.se/docs/manpage.html#--anyauth) might be
404 the Internet. To specify those with curl, run something like:
406 curl --proxy-user proxyuser:proxypassword curl.se
409 use [`--proxy-ntlm`](https://curl.se/docs/manpage.html#--proxy-ntlm), if
411 [`--proxy-digest`](https://curl.se/docs/manpage.html#--proxy-digest).
414 part, curl will prompt for the password interactively.
436 do it. Using curl, you can put anything you want in the referer-field and
439 Use curl to set the referer field with:
441 curl --referer http://www.example.come http://www.example.com
452 At times, you will see that getting a page with curl will not return the same
457 To make curl look like Internet Explorer 5 on a Windows 2000 box:
459 curl --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" [URL]
463 curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
474 Curl does not follow `Location:` headers by default, but will simply display
479 To tell curl to follow a Location:
481 curl --location http://www.example.com
483 If you use curl to POST to a site that immediately redirects you to another
485 [`--location`](https://curl.se/docs/manpage.html#-L) (`-L`) and
486 `--data`/`--form` together. Curl will only use POST in the first request, and
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 will 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` will show
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 bundle. Failing the verification will cause curl to deny the connection. You
593 must then use [`--insecure`](https://curl.se/docs/manpage.html#-k)
594 (`-k`) in case you want to tell curl to ignore that the server cannot be
598 the [`SSLCERTS` document](https://curl.se/docs/sslcerts.html).
601 curl to use that to verify the server's certificate:
603 curl --cacert ca-bundle.pem https://example.com/
609 Doing fancy stuff, you may need to add or change elements of a single curl
616 curl --data "<xml>" --header "Content-Type: text/xml" \
622 curl --header "Host:" http://www.example.com
627 curl --header "Destination: http://nowhere" http://example.com
631 It should be noted that curl selects which methods to use on its own
634 [`--request`](https://curl.se/docs/manpage.html#-X) / `-X` option you
635 can change the method keyword curl selects, but you will not modify curl's
637 can modify the method to a `PROPFIND` with `-X` and curl will still think it
641 curl -X POST http://example.org/
643 ... but curl will still think and act as if it sent a GET so it will not send
652 login forms work and how to login to them using curl.
655 will most certainly need to script things and do multiple curl invokes etc.
681 Many times when you run curl on a site, you will notice that the site does not
682 seem to respond the same way to your curl requests as it does to your
685 Then you need to start making your curl requests more similar to your
694 - Set user-agent (with [`-A`](https://curl.se/docs/manpage.html#-A)) to
697 - Set referer (with [`-E`](https://curl.se/docs/manpage.html#-E)) like