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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Setting and sending header

andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Setting and sending header

Post by andreykrasnodar »

Unfortunatelly the code below

Code: Select all

procedure TForm1.Test;
var
  Header: ICefStringMultimap;
  Request: ICefRequest;
  Data: ICefPostData;
begin
  Header := TCefStringMultimapOwn.Create;
  Request := TCefRequestRef.New;
  Header.Append('Referer', 'https://some-site.com');
  Request.Assign('https://mysite.com', '', nil, Header);
  Chromium2.Browser.MainFrame.LoadRequest(Request);
end
Opens website but does not send referrer.
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Setting and sending header

Post by dilfich »

Try this

Code: Select all

   Request := TCefRequestRef.New;
   Request.Assign(url, '', nil, Header);
   Request.SetReferrer(url, REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE);
   WB.Browser.MainFrame.LoadRequest(Request);
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting and sending header

Post by andreykrasnodar »

REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE
does not exist in old CEF versions
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting and sending header

Post by andreykrasnodar »

dilfich wrote: Fri Aug 07, 2020 8:22 am Try this

Code: Select all

   Request := TCefRequestRef.New;
   Request.Assign(url, '', nil, Header);
   Request.SetReferrer(url, REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE);
   WB.Browser.MainFrame.LoadRequest(Request);
Undeclared identifier: 'TCefRequestRef'
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Setting and sending header

Post by dilfich »

So update))
And so only like-minded people to look for, who specifically the old version will not put exactly, and from memory or in theory it is unlikely to suggest something.
See the source code, there's probably just a different name.
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Setting and sending header

Post by salvadordf »

andreykrasnodar wrote: Sun Aug 23, 2020 9:02 pm
dilfich wrote: Fri Aug 07, 2020 8:22 am Try this

Code: Select all

   Request := TCefRequestRef.New;
   Request.Assign(url, '', nil, Header);
   Request.SetReferrer(url, REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE);
   WB.Browser.MainFrame.LoadRequest(Request);
Undeclared identifier: 'TCefRequestRef'
Press CONTROL + SHIFT + F to search, select the "Search in directories" option, select the OldCEF4Delphi\source directory in the "Directories:" box, type "TCefRequestRef" in the "Text to" box at the top and click the "Ok" button.

You will see that TCefRequestRef is defined in uCEFRequest.pas

OldCEF4Delphi has all the classes that you had with dcef3 but they are in smaller files inside the "sources" directory.
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Setting and sending header

Post by dilfich »

you need to find SetReferrer and see what you need there.

Or Google, it's obviously faster)
For example, but I have no idea what your version is and what the procedures and functions.
https://stackoverflow.com/questions/129 ... h-chromium
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting and sending header

Post by andreykrasnodar »

dilfich wrote: Mon Aug 24, 2020 10:21 am So update))
And so only like-minded people to look for, who specifically the old version will not put exactly, and from memory or in theory it is unlikely to suggest something.
See the source code, there's probably just a different name.
I have updated to old CEF4Delphi and re-wrote my application.
Still does not send referer.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting and sending header

Post by andreykrasnodar »

salvadordf wrote: Mon Aug 24, 2020 10:33 am You will see that TCefRequestRef is defined in uCEFRequest.pas
Thanks. I have found and added it to 'uses'
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting and sending header

Post by andreykrasnodar »

dilfich wrote: Mon Aug 24, 2020 11:36 am For example, but I have no idea what your version is and what the procedures and functions.
https://stackoverflow.com/questions/129 ... h-chromium
Yes, I have tried this few days ago and found out that if Request.Method='POST', referer will work and when Request.Method is GET, application can not send referer.
P.S. My version is 2623
Post Reply