本文整理汇总了C#中Browser.SetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.SetHeader方法的具体用法?C# Browser.SetHeader怎么用?C# Browser.SetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Browser
的用法示例。
在下文中一共展示了Browser.SetHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomHostHeaderIsSent
public void CustomHostHeaderIsSent()
{
var browser = new Browser();
browser.Navigate("http://204.144.122.42");
Assert.That(browser.RequestData().RequestHeaders["host"], Is.EqualTo("204.144.122.42"), "Expected host header to be default from url.");
// I happen to know that this domain name is not in dns (my company owns it)
// but that ip (also ours) is serving content for said domain.
// Is there another way to confirm the overriden header is sent that does
// not depend on some random internet server?
browser.SetHeader("host:uscloud.asldkfhjawoeif.com");
browser.Navigate("http://204.144.122.42");
Assert.That(browser.RequestData().RequestHeaders["host"], Is.EqualTo("uscloud.asldkfhjawoeif.com"), "Expected the manually set host.");
}
示例2: AddHostHeaderDoesNotThrow
public void AddHostHeaderDoesNotThrow()
{
var browser = new Browser();
Assert.DoesNotThrow(() => browser.SetHeader("host:www.google.com"));
}