Thursday, January 10, 2013

Website Debugging with Curl : The Web Browser of the Gods

The Web Browser of the Gods

watch -d -n 1 curl -sv -b cookiejar.txt -c cookiejar.txt http://localhost:8080

For Gods who are mostly interested in the headers:


watch -d -n 1 curl -sv -b cookiejar.txt -c cookiejar.txt -o delete.me http://localhost:8080



Long Version


Curl's a nice way to analyse what's going on with a website:



When debugging a server running on your own machine:

curl http://localhost

If it's on port 8080

curl http://localhost:8080

If you're after a sub-path

curl http://localhost:8080/favicon.ico

I prefer:

curl -sv http://localhost:8080

-s turns off the information about download percentage, progress
-v adds the details of the header transaction

You can send both data and progress messages to a file with:

curl -sv http://localhost:8080 2&>curl.out

Poll the website every second, highlighting changes with:

watch -d -n 1 curl -sv http://localhost:8080

Pass in a cookie thus:

curl -sv http://localhost:8080 -b "yo=doom"

See the cookies that come back:

curl -sv http://localhost:8080 -c -

Save cookies that come back:

curl -sv http://localhost:8080 -b "yo=doom" -c cookiejar.txt

Or read and write cookies from a cookie file like:

curl -sv http://localhost:8080 -b cookiejar.txt -c cookiejar.txt

Finally, you can throw away the document itself and just display transaction and the cookies with:

curl -sv http://localhost:8080 -b "cook=ie" -c /dev/stderr >/dev/null




No comments:

Post a Comment