Sunday, July 12, 2009

How to modify http headers in Internet Explorer

When developing for the web, you may want to simulate various HTTP Header values for your application. This is easy in Firefox - there are a number of plugins that allow you to do this like Modify Headers.

However for IE6 it is more difficult. The best solution I have found is this one:

- Download Fiddler.
- Open the 'Customize Rules' window (Rules->Customize Rules...)
- find this function: static function OnBeforeRequest(oSession: Session)
- inside this function, add the header values that you would like to add, in this format:

oSession.oRequest["headerName"] = "headerValue";

-save


VoilĂ ! Internet Explorer will now accept your custom header values. You will probably need to clear your browser cookies before it takes effect.

10 comments:

vlad said...

its great. working for me, thanks

KMZack said...

where exactly to add that function? i got an error after save it

Daniel Alexiuc said...

Add it inside the function named "OnBeforeRequest(oSession: Session)".

Try adding it on the line immediately following that one.

KMZack said...

Shame on me i am still gor an error after save it.

Anonymous said...

I can't seem to get this working.

I'm following the steps:
1) Get Fiddler
2) Rules -> Customize Rules
3) Add header value items

But the headers still don't seem to be modified in IE. I'm using IE7, will it work for that version?

Daniel Alexiuc said...

I described the process to set request headers. It should work fine on IE7.

If you want to set response headers, you can use the filters tab in Fiddler. Check "use filters", and the "set response header" option.

Anonymous said...

tell please, how can i check that my hhtp header was really modified?

rohits arena said...

Thanks.Appreciate it

kidata said...

Guy, that's great!

Anonymous said...

it's great.. thanks for your post..