How to set custom “Host” header in HttpWebRequest?

后端 未结 5 964
自闭症患者
自闭症患者 2020-12-11 06:54

How can I set a custom Host header in HttpWebRequest? I know that normally this class doesn\'t allow you to do so but is there anyway to use reflection or something like tha

5条回答
  •  庸人自扰
    2020-12-11 07:25

    WebClient allows it.

    var client = new WebClient();
    client.Headers.Add( "Host", WebHeader );
    

    I couldn't tell you why. The documentation clearly states that Host is a system header.

提交回复
热议问题