0

现在我们可以使用 dotnetbrowser 捕获 http 请求并修改请求数据,那么我们是否可以像 fiddler 一样捕获 http(s) 和 ajax 响应并修改它(包括标头和数据主体)?现在我们使用 fiddler core 和 dotnetbrowser 来处理这个问题!

4

2 回答 2

0

当前版本的 DotNetBrowser 1.16 提供了注册自定义协议处理程序的能力,这些处理程序将用于拦截和处理标准 URL 方案(例如 http、https、ftp 等)和应用程序中声明的自定义方案的所有 URL 请求. 它允许根据需要修改 URL 响应。

注册协议处理程序:

//Registering the handler for the specified protocol
Browser.Context.ProtocolService.Register("https", new HttpsHandler());

自定义协议处理程序的实现:

//The instance of this type will handle the requests of the specified protocol
public class HttpsHandler : IProtocolHandler
{
    //This method should provide the response for the specified request
    public IUrlResponse Handle(IUrlRequest request)
    {
        string htmlContent = "Request Url: " + request.Url + "\n";
        return new UrlResponse(Encoding.UTF8.GetBytes(htmlContent));
    }
}

有关更多信息,您可以使用这篇文章:自定义协议处理程序

于 2018-07-30T09:24:05.103 回答
0

不幸的是,此功能在当前版本的 DotNetBrowser 中不可用,但我们正在研究将其添加到下一版本的 DotNetBrowser 的可能性。

于 2016-10-24T08:29:32.450 回答