fiddler: how to disable overwrite Header Host

前端 未结 4 1410
隐瞒了意图╮
隐瞒了意图╮ 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:06

    I couldn't get what I needed for the existing answers, but Eric Law's answer gave me what I needed to fix my issue. I was having a problem where I was calling a web server by IP address, and I had to add a Host header to get the right endpoint. Fiddler was changing the Host header to the IP address I was calling and removing my Host header value, which caused the call to fail. I added a line to Eric's script to solve this. I put the rule into OnBeforeRequest in the Fiddler Rules Script.

     if (oSession.BitFlags & SessionFlags.ProtocolViolationInRequest) 
        {
            var sOverride = oSession["X-Original-Host"];
    
            if (!String.IsNullOrEmpty(sOverride)) 
            {
                oSession["X-overrideHost"] = sOverride;
                oSession["ui-backcolor"] = "yellow";
                oSession.oRequest["Host"] = sOverride;
    
                // Be sure to bypass the gateway, otherwise overrideHost doesn't work
                oSession.bypassGateway = true;
            }
        }
    

    Took this Error:

    And changed it to this:

提交回复
热议问题