Page 1 of 1

CEF4 is not getting header value

Posted: Wed Jun 03, 2020 11:31 pm
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

CEF4 is not getting header value

Posted: Wed Jun 03, 2020 11:55 pm
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

Re: CEF4 is not getting header value

Posted: Thu Jun 04, 2020 7:47 am
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

Re: CEF4 is not getting header value

Posted: Thu Jun 04, 2020 4:30 pm
by leninjs
I used it and it worked well.

TChromium.CustomHeaderName
and TChromium.CustomHeaderValue.

Thank you