Curl Guides
Curl Guides
You can specify the type of HTTP request (GET, POST, PUT, etc.) using the appropriate flags,
and you can set headers or send data within the request.
The GET request is the default method curl uses if no method is explicitly specified.
curl http://testphp.vulnweb.com/
curl -v http://testphp.vulnweb.com/
• -v: Shows both the request sent and the response received, including headers.
To specify custom headers in your HTTP request (like Content-Type, Authorization, etc.),
use the -H option:
For POST requests, use the -X option to specify the request type, and -d (data) to send the
payload:
Here:
Alternatively, you can use the --form option for file uploads:
• application/json
• text/html
• application/x-www-form-urlencoded
Make sure you specify the correct Content-Type header with -H if necessary.
7. HTTP Methods
You can save the HTTP response body to a file using the -o (output) option:
To download a file with its original name, use -O (uppercase letter O):
curl -O http://testphp.vulnweb.com//file.zip
curl -I http://testphp.vulnweb.com/
This will return the HTTP status and headers like Content-Type, Content-Length, etc.
To display both the request and the response, including headers, you can use:
curl -v http://testphp.vulnweb.com/
• Measure Response Time: Use the -w (write-out) option to get the time metrics of a
request.
txt
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_starttransfer: %{time_starttransfer}\n
time_total: %{time_total}\n
You can specify basic HTTP authentication credentials with the -u option:
If the URL you request results in a redirect (HTTP 3xx), use the -L option to follow it:
curl -L http://testphp.vulnweb.com/
Option Description
-d Send data with the request (usually used with POST, PUT)
-L Follow redirects