fiddler: how to disable overwrite Header Host

前端 未结 4 1409
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 18:52

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\'         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 19:01

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

提交回复
热议问题