Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

http - fiddler: how to disable overwrite Header Host

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...