I implemented CefRequestHandler interface. In the OnBeforeBrowse method I want to add custom http header but it seems not work. The related code as below
virtual bool OnBeforeBrowse( CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame,
CefRefPtr< CefRequest > request, CefRequestHandler::NavType navType, bool isRedirect )
{
CefRequest::HeaderMap hdrMap;
request->GetHeaderMap(hdrMap);
hdrMap.insert(std::make_pair("Test", "test"));
request->SetHeaderMap(hdrMap);
return false;
}
The request parameter is passed as a pointer so I think the action performed on it should take effect, but actually not.
I'm new to use CEF library, I want't to know is there a way to add custom header before navigation? Thank you in advance!
You can't modify request there: CefRequestHandler::OnBeforeBrowse()
but try to implement this: CefRequestHandler::OnBeforeResourceLoad()