Difference between revisions of "CURL"
Jump to navigation
Jump to search
↑ http://man7.org/linux/man-pages/man1/curl.1.html
↑ https://docs.gitlab.com/ee/api/notification_settings.html#global-notification-settings
↑ https://stackoverflow.com/questions/3252851/how-to-display-request-headers-with-command-line-curl
(51 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{lowercase title}} | {{lowercase title}} | ||
− | [[wikipedia:CURL | + | [[wikipedia:CURL|cURL]] ([[1996]]) <ref>http://man7.org/linux/man-pages/man1/curl.1.html</ref> is a command-line tool for getting or sending data including files using URL syntax. cURL supports a range of common network protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DAP, DICT, TELNET, FILE, IMAP, POP3, SMTP and RTSP. |
+ | [[brew install curl]] | ||
+ | [[apt install curl]] | ||
− | == | + | == Examples == |
+ | * <code>[[curl --help]]</code> | ||
+ | * <code>curl -vvv https://google.com</code> | ||
+ | * <code>curl [[--insecure]] https://yourdomain.com</code> | ||
+ | * <code>curl https://google.com/file_to_download -o output_file_name</code> | ||
* <code>curl -sS https://google.com</code> | * <code>curl -sS https://google.com</code> | ||
+ | ::<code>-s [[--silent]] Avoid showing progress bar</code> | ||
+ | ::<code>-S --show-error</code> | ||
+ | * <code>[[curl -sSL]]</code> | ||
+ | ::<code>[[-L]], --location follow redirects</code> | ||
* <code>curl -u YOUR_USERNAME:YOUR_PASSWORD https://yourpasswordprotectedpage.com/</code> | * <code>curl -u YOUR_USERNAME:YOUR_PASSWORD https://yourpasswordprotectedpage.com/</code> | ||
* Save your cookies and reuse them: | * Save your cookies and reuse them: | ||
:<code>curl --user user:pass --cookie-jar ./somefile_with_your_cookies https://xyz.com/a</code> | :<code>curl --user user:pass --cookie-jar ./somefile_with_your_cookies https://xyz.com/a</code> | ||
:<code>curl --cookie ./omefile_with_your_cookiese https://xyz.com/b</code> | :<code>curl --cookie ./omefile_with_your_cookiese https://xyz.com/b</code> | ||
− | *<code>curl --header 'X-JFrog-Art-Api: 1234567890'</code> | + | * <code>[[curl --header]] 'X-JFrog-Art-Api: 1234567890'</code> |
+ | * <code>curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/notification_settings</code><ref>https://docs.gitlab.com/ee/api/notification_settings.html#global-notification-settings</ref> | ||
+ | * <code>[[curl -Is]] https://yourdomain.com/ | head -1</code> | ||
+ | |||
+ | * -m, [[--max-time]] | ||
+ | * <code>[[curl --compressed]]</code> | ||
+ | |||
* Upload a file: | * Upload a file: | ||
− | + | :<code>curl -u YOUR_USERNAME:YOUR_PASSWORD -T FILE_TO_UPLOAD https://yourpasswordprotectedpage.com/your_destionation</code> | |
− | + | ::<code>-T, --upload-file <file></code> | |
* [[Display HTTP response headers]]: | * [[Display HTTP response headers]]: | ||
: <code>curl -sD - -o /dev/null http://example.com</code><ref>https://stackoverflow.com/questions/3252851/how-to-display-request-headers-with-command-line-curl</ref> | : <code>curl -sD - -o /dev/null http://example.com</code><ref>https://stackoverflow.com/questions/3252851/how-to-display-request-headers-with-command-line-curl</ref> | ||
− | :: -s Avoid showing progress bar | + | ::-s Avoid showing progress bar |
− | :: -D Dump headers to a file, but - sends it to stdout | + | ::-D Dump headers to a file, but - sends it to stdout |
− | :: -o /dev/null Ignore response body | + | ::-o /dev/null Ignore response body |
+ | |||
+ | * <code>curl -XDELETE localhost:[[9200]]/index/type/documentID (Invoke-WebRequest -method DELETE http://localhost:9200/_all)</code> | ||
− | + | ||
+ | Offers the same features to fetch remote banner information from HTTP servers: | ||
+ | |||
+ | <code> curl -s -I 192.168.0.15 | grep -e "Server: "</code> | ||
+ | |||
+ | Other options: | ||
+ | -k, --insecure To accept [[self signed certificate]] | ||
+ | -L, --location | ||
== Advance usage== | == Advance usage== | ||
− | * Use cURL to measure request and response times: https://stackoverflow.com/a/22625150 | + | * Use cURL to measure request and response times: https://stackoverflow.com/a/22625150 |
− | + | ::<code>curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://www.google.com</code> | |
+ | == Errors == | ||
+ | * <code>[[curl: (52) Empty reply from server]]</code> | ||
+ | * <code>[[CURL Error (7): couldn't connect to host]]</code> | ||
+ | * <code>[[curl: (35) OpenSSL SSL connect: SSL ERROR SYSCALL in connection to]]</code> | ||
+ | * <code>[[curl: (47) Maximum (50) redirects followed]]</code> | ||
+ | == Related terms == | ||
+ | * [[JSON]] | ||
+ | * <code>[[opensearch-cli curl]]</code> | ||
+ | * [[Elasticsearch curl URLs]] | ||
+ | * [[Python requests]] library | ||
+ | * [[Scraping]] | ||
+ | * <code>[[get_url]]</code> [[ansible]] | ||
+ | * <code>[[kubectl run -it --rm]] test --image=[[curlimages/curl]] --restart=Never [[--]] [[/bin/sh]]</code> | ||
+ | * <code>[[pv]]</code> | ||
+ | * <code>[[cast rpc]]</code> | ||
== See also == | == See also == | ||
* {{wget}} | * {{wget}} | ||
− | * | + | * {{nc}} |
− | |||
* <code>[[iwr]]</code> (Invoke-WebRequest) [[PowerShell]] functionality | * <code>[[iwr]]</code> (Invoke-WebRequest) [[PowerShell]] functionality | ||
− | * | + | * {{lynx}} |
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:Networking]] | [[Category:Networking]] |
Revision as of 11:58, 21 August 2024
cURL (1996) [1] is a command-line tool for getting or sending data including files using URL syntax. cURL supports a range of common network protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DAP, DICT, TELNET, FILE, IMAP, POP3, SMTP and RTSP.
brew install curl apt install curl
Examples
curl --help
curl -vvv https://google.com
curl --insecure https://yourdomain.com
curl https://google.com/file_to_download -o output_file_name
curl -sS https://google.com
-s --silent Avoid showing progress bar
-S --show-error
-L, --location follow redirects
curl -u YOUR_USERNAME:YOUR_PASSWORD https://yourpasswordprotectedpage.com/
- Save your cookies and reuse them:
curl --user user:pass --cookie-jar ./somefile_with_your_cookies https://xyz.com/a
curl --cookie ./omefile_with_your_cookiese https://xyz.com/b
curl --header 'X-JFrog-Art-Api: 1234567890'
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/notification_settings
[2]curl -Is https://yourdomain.com/ | head -1
- Upload a file:
curl -u YOUR_USERNAME:YOUR_PASSWORD -T FILE_TO_UPLOAD https://yourpasswordprotectedpage.com/your_destionation
-T, --upload-file <file>
curl -sD - -o /dev/null http://example.com
[3]- -s Avoid showing progress bar
- -D Dump headers to a file, but - sends it to stdout
- -o /dev/null Ignore response body
curl -XDELETE localhost:9200/index/type/documentID (Invoke-WebRequest -method DELETE http://localhost:9200/_all)
Offers the same features to fetch remote banner information from HTTP servers:
curl -s -I 192.168.0.15 | grep -e "Server: "
Other options:
-k, --insecure To accept self signed certificate -L, --location
Advance usage
- Use cURL to measure request and response times: https://stackoverflow.com/a/22625150
curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://www.google.com
Errors
curl: (52) Empty reply from server
CURL Error (7): couldn't connect to host
curl: (35) OpenSSL SSL connect: SSL ERROR SYSCALL in connection to
curl: (47) Maximum (50) redirects followed
Related terms
- JSON
opensearch-cli curl
- Elasticsearch curl URLs
- Python requests library
- Scraping
get_url
ansiblekubectl run -it --rm test --image=curlimages/curl --restart=Never -- /bin/sh
pv
cast rpc
See also
wget
,cURL
,links
,lynx
,elinks
,w3m
,httpie, opensearch-cli curl
,--no-check-certificate, wget --help
telnet
,netcat, nc, nc -l
,ncat
,socat, ngrok
iwr
(Invoke-WebRequest) PowerShell functionality- lynx, links (browser), lynx (browser), Elinks (browser) command line browsers
Advertising: