所用版本:86.0.241
参考文档:
https://github.com/cefsharp/CefSharp/wiki/General-Usage#response-filtering
public class CustomResourceRequestHandler : CefSharp.Handler.ResourceRequestHandler
{
protected override void OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
{
//哪个url
Trace.WriteLine(request.Url);
//对应地址的Headers
Trace.WriteLine(response.Headers["date"]);
}
}
public class CustomRequestHandler : CefSharp.Handler.RequestHandler
{
protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
{
return new CustomResourceRequestHandler();
}
}
//使用
chromiumWebBrowser1.RequestHandler = new CustomRequestHandler();
这样请求和响应都能拿到了,这种设计还挺新颖。