Posts Tagged “curl”

Sometimes it becomes necassary to test a link from a particular referrer. This is easily done with the following curl statement:

curl -I -H “Referer: http://your_referrer_here” http://lwww.somewhere.com/link/to/file

The ‘-I’ is used to display header information and the ‘-H’ is used to specify other header information. Lets take a look at the header information of a normal curl:

[user@8bitpipe.com ~]$ curl -I http://www.magicdeckvortex.com/images/article_images/sarpadian_empires/MindstabThrull3.jpg
HTTP/1.1 200 OK
Date: Mon, 03 Jan 2011 14:17:13 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.12
Last-Modified: Mon, 18 May 2009 06:30:44 GMT
ETag: “40003d-1060c-46a29ef124d00″
Accept-Ranges: bytes
Content-Length: 67084
Content-Type: image/jpeg

As you can see, this is returning an image file as it should. Now lets specify a referrer (basically making it look like some other website is hotlinking their image).


[user@8bitpipe.com ~]$ curl -I -H “Referer: http://www.8bitpipe.com”

http://www.magicdeckvortex.com/images/article_images/sarpadian_empires/MindstabThrull3.jpg

HTTP/1.1 403 Forbidden
Date: Mon, 03 Jan 2011 14:32:24 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.12
Content-Type: text/html; charset=iso-8859-1

As you can see, the server has denied our request. Hopefully this will help trouble shoot issues.

Comments No Comments »