Using cURL for Testing & Troubleshooting

About curl

cURL

cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. It was first released in 1997. The name stands for "Client URL".

It is useful in many applications and languages, or simply on its own for testing and troubleshooting purposes.


Quick Reference

Requesting a webpage: curl

Command:

curl https://ddg.hostnetworks.net/cURL

Output:

nick@AS4851: ~$ curl https://ddg.hostnetworks.net/cURL; echo
Found

Display response headers with Request: curl -i

Command:

curl -i https://ddg.hostnetworks.net/cURL

Output:

nick@AS4851: ~$ curl -i https://ddg.hostnetworks.net/cURL
HTTP/2 302
location: https://duckduckgo.com/cURL
content-type: text/plain; charset=utf-8
content-length: 5
date: Tue, 08 Oct 2019 01:16:22 GMT

Found

Force a request for a hostname to a different IP: curl --resolve

Command:

curl --resolve ddg.hostnetworks.net:443:202.174.96.227 https://ddg.hostnetworks.net:443/cURL -i

Output:

nick@AS4851: ~$ MyHost="ddg.hostnetworks.net"; curl --resolve "${MyHost}:443:202.174.96.227" https://${MyHost}:443/cURL -i
HTTP/2 302
location: https://duckduckgo.com/cURL
content-type: text/plain; charset=utf-8
content-length: 5
date: Tue, 08 Oct 2019 01:19:51 GMT

Found

Some additional curl command line options:
  • -A - Set the User Agent string
  • -H - Set a new Host header field
  • -I - Makes a HEAD HTTP request
  • -i - Shows HTTP Header as well as the response

Further Resources

Still in need of help? For speedy assistance our friendly staff are always ready to help via our helpdesk, on Twitter, through our website, or directly via email to support.