Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

CEF4 is not getting header value

Post Reply
leninjs
Posts: 3
Joined: Wed Jun 03, 2020 10:32 pm

CEF4 is not getting header value

Post by leninjs »

there is a procedure that worked in an earlier version of CEF4Delphi that stopped working in that version.
the code passes a customized header with login and password data.
that the page takes from the header and automates the entry on the page.

Request := TCefRequestRef.New;
Request.Url := 'https://reds.cfconnect.com/user/acao/W9';
Request.Method := 'GET';

sUsuario := "loginFlex:password123"
Header := TCefStringMultimapOwn.Create;
Header.Append('Authorization', 'Flexmobile ' + sUsuario);
Header.Append('ShowToolbar', 'false');

Request.SetHeaderMap(Header);

oFormWeb.UrlRequest := Request;

xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx

protected
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEFBROWSER_CREATED;

procedure TForm.BrowserCreatedMsg(var aMessage: TMessage);
begin
CEFWindowParent1.UpdateSize;
if UrlString <> EmptyStr then
wb.LoadURL(UrlString)
else
wb.Browser.MainFrame.LoadRequest(UrlRequest);
end;

But in the last version it stopped working

Has it changed the way to do this? or is it some mistake?

Best regards

Lenin
leninjs
Posts: 3
Joined: Wed Jun 03, 2020 10:32 pm

CEF4 is not getting header value

Post by leninjs »

CEF4 is not getting header value

I have a code that worked on a previous version of CEFDelphi and stopped working with updating the component to the latest version.
in the version it worked:
- libcef.dll version : 3.3396.1777.0

in the last version it is not working:
- libcef.dll version : 83.3.11.0

the code passed a login and password value to a custom header.
It takes values from the website header to authenticate.
But it's not working anymore.



Request := TCefRequestRef.New;
Request.Url := https://reds.connect.com:8081/user/acao/W9;
Request.Method := 'GET';

Header := TCefStringMultimapOwn.Create;
Header.Append('Authorization', 'Flexmobile ' + "Login123:password123");
Header.Append('ShowToolbar', 'false');

Request.SetHeaderMap(Header);

oFormWeb.UrlRequest := Request;

xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx

protected
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEFBROWSER_CREATED;
public

procedure TfrmVisualizaMapa.BrowserCreatedMsg(var aMessage: TMessage);
begin
CEFWindowParent1.UpdateSize;
if UrlString <> EmptyStr then
wb.LoadURL(UrlString)
else
wb.Browser.MainFrame.LoadRequest(UrlRequest);
end;

Best Regards

Lenin
User avatar
salvadordf
Posts: 4040
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: CEF4 is not getting header value

Post by salvadordf »

Hi

The LoadRequest procedure fails unless you first navigate to the request origin using some other mechanism (LoadURL, link click, etc).

You may see this error :
"bad IPC message" reason INVALID_INITIATOR_ORIGIN (213)
If all you need is to add some custom HTTP headers consider using the TChromium.OnBeforeResourceLoad event or using the TChromium.CustomHeaderName and TChromium.CustomHeaderValue properties.

Here you have an example :
https://github.com/salvadordf/CEF4Delph ... r.pas#L438
leninjs
Posts: 3
Joined: Wed Jun 03, 2020 10:32 pm

Re: CEF4 is not getting header value

Post by leninjs »

I used it and it worked well.

TChromium.CustomHeaderName
and TChromium.CustomHeaderValue.

Thank you
Post Reply