Useful cURL commands

Working with ADC appliances and with web apps for sure you will need to do some testing. cURL is a nice tool you have on Linux systems and now on windows using Windows 10โ€™s Bash Shell via the Windows Subsystem for Linux. Here are some examples I am using:

#cURL with a cookie:
curl -k -vvv --cookie "cookiename=3877714166383783595765382943414841579894" https://10.10.10.10 

#cURL with a useragent:
curl -k -A "myuseragnet/1.1" https://10.10.10.10 

#cURL with a different method than GET (in this case OPTIONS):
curl -k -X OPTIONS https://10.10.10.10  

#cURL with a http header  X-Forwarded-Host  :
curl -k -vvv --header "X-Forwarded-Host: www.example.com" https://10.10.10.10   

#cURL  POST request: 
curl -k -X POST -d @filename.txt http://example.com/path/to/resource --header "Content-Type:application/json" https://10.10.10.10 

#Using cURL  for security testing:
curl -vvv "http://10.10.10.10///example-http/../xyz/HTTPServlet" --path-as-is

#Testing response times with cURL
curl -k  -o /dev/null -s -w 'Connect: %{time_connect}\nStart Transfer: %{time_starttransfer}\nTotal: %{time_total}\n'  https://www.google.com

#Netscaler API calls with cURL 
curl -X GET -H "Content-Type:application/json" -H "X-NITRO-USER: nsroot" -H "X-NITRO-PASS: pass" "http://10.10.10.10/nitro/v1/config/csvserver"

About the author

Mihai is a Senior Network Engineer with more than 15 years of experience