Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fiddler: how to disable overwrite Header Host

Tags:

http

host

fiddler

When using Fiddler, it pops up an alert dialog.

Fiddler has detected a protocol violation in session #14.

The Request's Host header did not match the URL's host component.

URL Host:   proxy.music.pp.com
Header Host:    119.147.22.41

And it shows that Fiddler changed HTTP Header's host to "proxy.music.pp.com", is there any way to disable Fiddler changing it?

like image 939
bettermanlu Avatar asked Aug 08 '12 10:08

bettermanlu


2 Answers

From my book:

Swap the Host Header

When Fiddler gets a request whose URL doesn’t match its Host header, the original Host value is stored in the session flag X-Original-Host and then the Host value is replaced with the host parsed from the URL. The following script, placed inside your FiddlerScript's BeforeRequest function, reverses behavior by routing the request to the host specified by the original Host header.

if (oSession.BitFlags & SessionFlags.ProtocolViolationInRequest) 
{
  var sOverride = oSession["X-Original-Host"];
  if (!String.IsNullOrEmpty(sOverride)) 
  {
    oSession["X-overrideHost"] = sOverride;
    oSession["ui-backcolor"] = "yellow";

    // Be sure to bypass the gateway, otherwise overrideHost doesn't work
    oSession.bypassGateway = true;
  }
}
like image 131
EricLaw Avatar answered Sep 19 '22 12:09

EricLaw


You can do this with rules.

Go into Customize rules, and find the function: OnBeforeRequest(oSession: Session)

Then add the following as the last line of that function:

if (oSession.HostnameIs("proxy.music.pp.com")) { oSession.host = "119.147.22.41"; }
like image 21
Peter Avatar answered Sep 19 '22 12:09

Peter