From 04469e66fa3262d06ba4de2e130029cde4524526 Mon Sep 17 00:00:00 2001 From: Fazle Arefin Date: Sun, 28 Jul 2024 00:13:47 +1000 Subject: [PATCH] curl: edit page (#13310) --------- Co-authored-by: spageektti Co-authored-by: Lena <126529524+acuteenvy@users.noreply.github.com> --- pages/common/curl.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pages/common/curl.md b/pages/common/curl.md index 15be264a1..7f3396124 100644 --- a/pages/common/curl.md +++ b/pages/common/curl.md @@ -1,37 +1,37 @@ # curl > Transfers data from or to a server. -> Supports most protocols, including HTTP, FTP, and POP3. +> Supports most protocols, including HTTP, HTTPS, FTP, SCP, etc. > More information: . -- Download the contents of a URL to a file: +- Make an HTTP GET request and dump the contents in `stdout`: -`curl {{http://example.com}} --output {{path/to/file}}` +`curl {{https://example.com}}` -- Download a file, saving the output under the filename indicated by the URL: +- Make an HTTP GET request, fo[L]low any `3xx` redirects, and [D]ump the reply headers and contents to `stdout`: -`curl --remote-name {{http://example.com/filename}}` +`curl --location --dump-header - {{https://example.com}}` -- Download a file, following location redirects, and automatically continuing (resuming) a previous file transfer and return an error on server error: +- Download a file, saving the [O]utput under the filename indicated by the URL: -`curl --fail --remote-name --location --continue-at - {{http://example.com/filename}}` +`curl --remote-name {{https://example.com/filename.zip}}` -- Send form-encoded data (POST request of type `application/x-www-form-urlencoded`). Use `--data @file_name` or `--data @'-'` to read from STDIN: +- Send form-encoded [d]ata (POST request of type `application/x-www-form-urlencoded`). Use `--data @file_name` or `--data @'-'` to read from `stdin`: -`curl --data {{'name=bob'}} {{http://example.com/form}}` +`curl -X POST --data {{'name=bob'}} {{http://example.com/form}}` -- Send a request with an extra header, using a custom HTTP method: +- Send a request with an extra header, using a custom HTTP method and over a pro[x]y (such as BurpSuite), ignoring insecure self-signed certificates: -`curl --header {{'X-My-Header: 123'}} --request {{PUT}} {{http://example.com}}` +`curl -k --proxy {{http://127.0.0.1:8080}} --header {{'Authorization: Bearer token'}} --request {{GET|PUT|POST|DELETE|PATCH|...}} {{https://example.com}}` -- Send data in JSON format, specifying the appropriate content-type header: +- Send data in JSON format, specifying the appropriate Content-Type [H]eader: `curl --data {{'{"name":"bob"}'}} --header {{'Content-Type: application/json'}} {{http://example.com/users/1234}}` -- Pass a username and prompt for a password to authenticate to the server: - -`curl --user {{username}} {{http://example.com}}` - - Pass client certificate and key for a resource, skipping certificate validation: `curl --cert {{client.pem}} --key {{key.pem}} --insecure {{https://example.com}}` + +- Resolve a hostname to a custom IP address (similar to editing the `/etc/hosts` file for custom DNS resolution): + +`curl --resolve {{example.com}}:{{80}}:{{127.0.0.1}} {{http://example.com}}`