QA Graphic

Fake Referer for Testing

curl is a great tool for QA

This is a sample QA task that I had many years ago:

A customer website wanted to acknowledge a particular set of users that found the website via a link on a partner site. They wanted me to test that users from one website saw one version of the site and everyone else got the typical content.

To perform this task, I used the Unix curl tool to get the job done.

-

This "hack" is useful when you want to fake a referer from a particular website, you can "dump" the results as an HTML file to verify the results was a success. It also helps if you have access to the apache logs to verify the referer was pass through.

CURL Config File

-

curl --config test.txt

-

In the config file:

-
# --- Example file ---
url = "http://www.cryan.com/Boston/"
output = "cia.html"
referer = "http://www.cia.gov" -
user-agent = "superagent/1.0"
# and fetch another URL too
url = http://www.cryan.com/Boston/"
output = "yahoo.html"
referer = "http://www.yahoo.com"
# and fetch another URL too
url = "http://www.cryan.com/Boston/"
output = "bing.html"
referer = "http://www.bing.com"

Sample Output

This is what you see when you run the command:

curl --config sample.txt
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 10813    0 10813    0     0  35677      0 --:--:-- --:--:-- --:--:-- 35686
100   315  100   315    0     0   3924      0 --:--:-- --:--:-- --:--:--  3924
100   311  100   311    0     0   3905      0 --:--:-- --:--:-- --:--:--  3905

Learn More

You can learn more cool tricks with CURL on the "man" page: curl - How To Use