如何使用华廷与特定的HTTP引用和查询字符串来模拟HTTP请求? [英] How to simulate http request using WatiN with specific HTTP referrer and query string?

查看:155
本文介绍了如何使用华廷与特定的HTTP引用和查询字符串来模拟HTTP请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用华廷去一个特定的网页,我怎么能假的HTTP引用一个查询字符串(即请求是来自谷歌的搜索与查询字符串q = SEARCH_TERM)?因此,我可以确认响应头有301重定向的具体来源网址。

我可能需要使用 FiddlerCore 表现得像一个中间人来设置自定义的引荐,但我不知道该怎么做,只是还没有。

我使用ASP.NET与C#。

谢谢!

  //华廷
Browser.GoTo(URL);


解决方案

我需要做类似下面:

  //会话FiddlerCore.Fiddler的定制版本
//有关细节BeforeRequest - > http://fiddler.wikidot.com/fiddlercore-demo
session.BeforeRequest + = SESS =>
    sess.oRequest
        .headers
        。加(
            引荐
            http://www.i-am-middle-man.com/q=black
        );session.BeforeResponse + = SESS =>
        {
            //sess.oResponse.headers.HTT$p$psponse$c$c
            //sess.oResponse.headers[\"Host]
        };VAR处理器= WatiNHandler(BrowserTypes.IE);
handler.GoTo(http://www.my-url.com/);

When I use WatiN to go to a specific web page, how can I fake the HTTP referrer with a query string (i.e. request is from google search with query string q=search_term)? So I can verify that the response header has the 301 redirect for specific referrer URL.

I may need to use FiddlerCore to act like a middle man to set the custom referrer but I am not sure how to do that just yet.

I am using ASP.NET with C#.

Thanks!

//WatiN
Browser.GoTo(url);

解决方案

I needed to do something similar to below:

// session is a custom version of FiddlerCore.Fiddler
// details about BeforeRequest -> http://fiddler.wikidot.com/fiddlercore-demo
session.BeforeRequest += sess =>
    sess.oRequest
        .headers
        .Add(
            "Referer",
            "http://www.i-am-middle-man.com/q=black"
        );

session.BeforeResponse += sess =>
        {
            //sess.oResponse.headers.HTTPResponseCode
            //sess.oResponse.headers["Host"]
        };

var handler = WatiNHandler(BrowserTypes.IE);
handler.GoTo("http://www.my-url.com/");

这篇关于如何使用华廷与特定的HTTP引用和查询字符串来模拟HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆