Friday, March 1, 2013

HTTP Request Headers Testing

This is a trick I’ve been using for a while, but I wanted to share.

Sometimes third party software requests your Web Pages/Services and pass data via the HTTP Request Headers.

If you want to simulate these requests you can do so with Fiddler. Fiddler acts as a “man in the middle” for all the requests coming from your browser. Therefore, it has the ability to alter your HTTP requests before they are passed along to the appropriate destination.

Here is how you add a header to your browser requests.

Launch Fiddler and select Rules > Custom Rules…

Find the function called

static function OnBeforeRequest(oSession: Session)

Within this function you can add items to your request header by assigning key/value combination to the “oSession.oRequest” array.

Here’s an example:

static function OnBeforeRequest(oSession: Session)
{ 
    oSession.oRequest["Custom_Header_Key"] = "Custom Header Value";
}

Now any request from a browser will contain that value. Including localhost requests

2013-03-01_1427

For more information about Custom Rules, I encourage your to visit the Fiddler Script Cookbook