• 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 invoke `curl --help` or `curl --manual` to get basic information about it.
17 Curl is not written to do everything for you. It makes the requests, it gets
33 The client, curl, sends a HTTP request. The request contains a method (like
41 Using curl's option [`--verbose`](https://curl.se/docs/manpage.html#-v)
42 (`-v` as a short option) will display what kind of commands curl sends to the
46 understand the curl<->server interaction.
49 [`--trace`](https://curl.se/docs/manpage.html#-trace) and
50 [`--trace-ascii`](https://curl.se/docs/manpage.html#--trace-ascii)
51 offer even more details as they show **everything** curl sends and
54 curl --trace-ascii debugdump.txt http://www.example.com/
61 [`--trace-time`](https://curl.se/docs/manpage.html#--trace-time) option
64 curl --trace-ascii d.txt --trace-time http://example.com/
68 By default curl sends the response to stdout. You need to redirect it
77 https://curl.se or https://yourbank.com a million times. RFC 3986 is the
83 address and that's what curl will communicate with. Alternatively you specify
87 IP address for a host name than what would otherwise be used, by using curl's
88 [`--resolve`](https://curl.se/docs/manpage.html#--resolve) option:
90 curl --resolve www.example.org:80:127.0.0.1 http://www.example.org/
94 Each protocol curl supports operates on a default port number, be it over TCP
101 curl http://www.example.org:1234/
105 need to specify that proxy's port number separately from what curl needs to
108 curl --proxy http://proxy.example.org:4321 http://remote.example.org/
119 curl http://user:password@example.org/
123 curl -u user:password http://example.org/
144 curl https://curl.se
150 use curl's [`--include`](https://curl.se/docs/manpage.html#-i) (`-i`)
156 [`--head`](https://curl.se/docs/manpage.html#-I) (`-I`) option which
157 will make curl issue a HEAD request. In some special cases servers deny the
167 A single curl command line may involve one or many URLs. The most common case
174 curl http://url1.example.com http://url2.example.com
176 If you use [`--data`](https://curl.se/docs/manpage.html#-d) to POST to
182 curl --data name=curl http://url1.example.com http://url2.example.com
189 [`--next`](https://curl.se/docs/manpage.html#-:) option. It is basically
194 When curl reaches the `--next` on the command line, it'll sort of reset the
200 curl -I http://example.com --next http://example.com
204 curl -d score=10 http://example.com/post.cgi --next http://example.com/results.html
244 To make curl do the GET form post for you, just enter the expected created
247 curl "http://www.example.com/when/junk.cgi?birthyear=1905&press=OK"
270 And to use curl to post this form with the same data filled in as before, we
273 curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when.cgi
278 The data you send to the server MUST already be properly encoded, curl will
283 Recent curl versions can in fact url-encode POST data for you, like this:
285 curl --data-urlencode "name=I am Daniel" http://www.example.com
287 If you repeat `--data` several times on the command line, curl will
310 To post to a form like this with curl, you enter a command line like:
312 curl --form upload=@localfilename --form press=OK [URL]
332 To POST this with curl, you won't have to think about if the fields are
333 hidden or not. To curl they're all the same:
335 curl --data "birthyear=1905&press=OK&person=daniel" [URL]
339 When you're about fill in a form and send to a server by using curl instead
358 Put a file to a HTTP server with curl:
360 curl --upload-file uploadfile http://www.example.com/receive.cgi
368 doing. The Basic authentication used in HTTP (which is the type curl uses by
373 To tell curl to use a user and password for authentication:
375 curl --user name:password http://www.example.com
381 [`--ntlm`](https://curl.se/docs/manpage.html#--ntlm),
382 [`--digest`](https://curl.se/docs/manpage.html#--digest),
383 [`--negotiate`](https://curl.se/docs/manpage.html#--negotiate) or even
384 [`--anyauth`](https://curl.se/docs/manpage.html#--anyauth) might be
392 the Internet. To specify those with curl, run something like:
394 curl --proxy-user proxyuser:proxypassword curl.se
397 use [`--proxy-ntlm`](https://curl.se/docs/manpage.html#--proxy-ntlm), if
399 [`--proxy-digest`](https://curl.se/docs/manpage.html#--proxy-digest).
402 part, curl will prompt for the password interactively.
424 do it. Using curl, you can put anything you want in the referer-field and
427 Use curl to set the referer field with:
429 curl --referer http://www.example.come http://www.example.com
440 At times, you will see that getting a page with curl will not return the same
445 To make curl look like Internet Explorer 5 on a Windows 2000 box:
447 curl --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" [URL]
451 curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
462 Curl does not follow `Location:` headers by default, but will simply display
467 To tell curl to follow a Location:
469 curl --location http://www.example.com
471 If you use curl to POST to a site that immediately redirects you to another
473 [`--location`](https://curl.se/docs/manpage.html#-L) (`-L`) and
474 `--data`/`--form` together. curl will only use POST in the first request, and
479 Browser typically support at least two other ways of redirects that curl
499 into a single logical session. To be able to use curl in such occasions, we
506 curl is to add them on the command line like:
508 curl --cookie "name=Daniel" http://www.example.com
510 Cookies are sent as common HTTP headers. This is practical as it allows curl
511 to record cookies simply by recording headers. Record cookies with curl by
512 using the [`--dump-header`](https://curl.se/docs/manpage.html#-D) (`-D`)
515 curl --dump-header headers_and_cookies http://www.example.com
518 [`--cookie-jar`](https://curl.se/docs/manpage.html#-c) option described
521 Curl has a full blown cookie parsing engine built-in that comes in use if you
525 you run curl like:
527 curl --cookie stored_cookies_in_file http://www.example.com
529 Curl's "cookie engine" gets enabled when you use the
530 [`--cookie`](https://curl.se/docs/manpage.html#-b) option. If you only
531 want curl to understand received cookies, use `--cookie` with a file that
532 doesn't exist. Example, if you want to let curl understand cookies from a
536 curl --cookie nada --location http://www.example.com
538 Curl has the ability to read and write cookie files that use the same file
542 and by using the `--cookie-jar` (`-c`) option you'll make curl write a new
545 curl --cookie cookies.txt --cookie-jar newcookies.txt \
561 Curl supports encrypted fetches when built to use a TLS library and it can be
562 built to use one out of a fairly large set of libraries - `curl -V` will show
563 which one your curl was built to use (if any!). To get a page from a HTTPS
564 server, simply run curl like:
566 curl https://secure.example.com
571 you claim to be, as an addition to normal passwords. Curl supports client-
573 need to enter before the certificate can be used by curl. The pass phrase
575 curl queries for it. Use a certificate with curl on a HTTPS server like:
577 curl --cert mycert.pem https://secure.example.com
579 curl also tries to verify that the server is who it claims to be, by
581 bundle. Failing the verification will cause curl to deny the connection. You
582 must then use [`--insecure`](https://curl.se/docs/manpage.html#-k)
583 (`-k`) in case you want to tell curl to ignore that the server can't be
587 the [SSLCERTS document](https://curl.se/docs/sslcerts.html).
590 curl to use that to verify the server's certificate:
592 curl --cacert ca-bundle.pem https://example.com/
598 Doing fancy stuff, you may need to add or change elements of a single curl
604 curl --data "<xml>" --header "Content-Type: text/xml" \
610 curl --header "Host:" http://www.example.com
615 curl --header "Destination: http://nowhere" http://example.com
619 It should be noted that curl selects which methods to use on its own
622 [`--request`](https://curl.se/docs/manpage.html#-X) / `-X` option you
623 can change the method keyword curl selects, but you will not modify curl's
625 can modify the method to a `PROPFIND` with `-X` and curl will still think it
629 curl -X POST http://example.org/
631 ... but curl will still think and act as if it sent a GET so it won't send
640 login forms work and how to login to them using curl.
643 will most certainly need to script things and do multiple curl invokes etc.
669 Many times when you run curl on a site, you'll notice that the site doesn't
670 seem to respond the same way to your curl requests as it does to your
673 Then you need to start making your curl requests more similar to your
682 - Set user-agent (with [`-A`](https://curl.se/docs/manpage.html#-A)) to
685 - Set referer (with [`-E`](https://curl.se/docs/manpage.html#-E)) like