I'm new to this forum and I know that the following question is a little bit "odd" but nevertheless I thought I might give this a try... So, I noticed the following:
LoadRequest() requires a previous LoadURL() - or a similar event - to work properly.
Since I need to perform a LoadRequest() as the first and only event, the workaround I used for this was to load a blank page using LoadURL() and then perform the LoadRequest() action.
The following (sample) code worked fine with CEF 76.1.13 and its Chromium version - every time with no problems whatsoever:
- Code: Select all
frame->LoadURL("about:blank");
CefRefPtr<CefRequest> cefrequest(CefRequest::Create());
cefrequest->SetURL(CefString(url));
cefrequest->SetMethod("GET");
cefrequest->SetHeaderByName("x-login-credentials", CefString(accessToken), true);
cefrequest->SetFlags(UR_FLAG_ALLOW_STORED_CREDENTIALS);
frame->LoadRequest(cefrequest);
When I upgraded my CEF to 80.0.8 (and its Chromium version, of course) with no other changes involved this no longer worked, at least the first LoadRequest() didn't do anything. Instead, it simply shows the blank page.
A subsequent repeat of the very same LoadRequest() seemed to work nicely as before, though.
After a while I figured out that a sleep of 500ms between LoadURL() and LoadRequest() would also make the first LoadRequest() attempt work, so I modified the code to look like this:
- Code: Select all
frame->LoadURL("about:blank");
Sleep(500); // workaround so that this still works with CEF 80.0.8
CefRefPtr<CefRequest> cefrequest(CefRequest::Create());
cefrequest->SetURL(CefString(url));
cefrequest->SetMethod("GET");
cefrequest->SetHeaderByName("x-login-credentials", CefString(accessToken), true);
cefrequest->SetFlags(UR_FLAG_ALLOW_STORED_CREDENTIALS);
frame->LoadRequest(cefrequest);
So, in essence, this works even though this workaround is certainly not something that I would like to use (permanently).
Is there anyone who might know why this "sleep" is necessary now (is there a timing issue) or - even better - can help me with the "proper" use of a LoadRequest()?
The problem I'm trying to solve is that the LoadRequest() should be the first and only request to be processed; the LoadURL() is just there to make LoadRequest() work at all.
Since log-in credentials are supposed to be transmitted as header data I currently see no other way but using LoadRequest() - or is there another way that I don't see?
Thank you very much in advance & best regards!