I'm trying to change or remove cookies in request headers via OnBeforeResourceLoad:
- Code: Select all
virtual CefResourceRequestHandler::ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback) override
{
CefRequest::HeaderMap headerMap;
(*request).GetHeaderMap(headerMap);
std::string my_first;
std::string my_second;
std::string my_find_phrase = "cookie";
for (auto& i : headerMap)
{
my_first = i.first.ToString();
my_second = i.second.ToString();
if (my_first.size() == my_find_phrase.size())
{
int cntr = 0;
for (int z = 0; z < my_find_phrase.size(); z++)
{
if (my_first[z] == my_find_phrase[z] || my_first[z] == my_find_phrase[z] - 32)
{
cntr++;
}
}
if (cntr == my_first.size())
{
i.second = "cookie_bla_bla";
}
}
(*request).SetHeaderMap(headerMap);
}
}
Well, that is, I'm looking for a header called Cookies in the headerMap and changing its value to non-existent.
And everything is replaced perfectly, the Cookie value changes - I see it in GetResourceResponseFilter - that is, I see it in the request object after the request has been made, the cookies have been changed.
But here's the problem: I intercept cookies and change them to non-existent ones, but the site that I load still sees my authorization, the site somehow understands who I am. That is, the CEF browser somehow still sends the site information about "who I am", but in the http request headers there are no more headers in which such information could be send.
Maybe you can suggest how this can happen?