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.

Accept-Language I can't change it.

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

Re: Accept-Language I can't change it.

Post by salvadordf »

If you just want to configure Chromium to avoid sending the referrer then set TChromiumCore.SendReferrer to False.

If you want replace the referrer header with a custom value then use the method described in the following link :
https://www.briskbard.com/forum/viewtopic.php?p=9766#p9766

If that doesn't work then Chromium is blocking any change of that header.
sodlf159
Posts: 90
Joined: Thu Nov 09, 2023 1:55 pm

Re: Accept-Language I can't change it.

Post by sodlf159 »

ICefRequest POST > Chromium1.LoadRequest(TempRequest); >

Chromium1BeforeResourceLoad What if I want to change the Referrer of just one specific URL?

TempHeaderMap.Append('Referer', 'https://google.com');
It is not added.
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Accept-Language I can't change it.

Post by salvadordf »

If Chromium allows modifying that header, it should be added in the TChromiumCore.OnBeforeResourceLoad event.

Identify the request by the URL using "request.Url" and follow the steps we discussed earlier :
https://www.briskbard.com/forum/viewtopic.php?p=9766#p9766

Create a TCefStringMultimapOwn instance, copy all headers except the "referer" and add you custom referer header. Then call request.SetHeaderMap with the new TCefStringMultimapOwn :
https://github.com/salvadordf/CEF4Delphi/blob/5ae265e9d3ce7076bda56c6429a642d5c76b83ef/demos/Delphi_VCL/OAuth2Tester/uOAuth2TesterFrm.pas#L359
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Accept-Language I can't change it.

Post by dilfich »

When opening the site once, you can specify the referrer like this

Code: Select all

var
  TempParams: ICefDictionaryValue;
begin
 try
  TempParams := TCefDictionaryValueRef.New;
  TempParams.SetString('url', 'https://www.briskbard.com/forum/posting.php?mode=reply&t=2289');
  TempParams.SetString('referrer', 'https://www.google.com/search');
  FChromium.ExecuteDevToolsMethod(0, 'Page.navigate', TempParams);
 finally
  TempParams:= nil;
 end;
end;
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-navigate
sodlf159
Posts: 90
Joined: Thu Nov 09, 2023 1:55 pm

Re: Accept-Language I can't change it.

Post by sodlf159 »

That's not the way.

I would like to change the referrer to a specific URL that is redirected to LoadRequest.
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Accept-Language I can't change it.

Post by dilfich »

sodlf159 wrote: Mon Jun 03, 2024 10:10 am I would like to change the referrer to a specific URL that is redirected to LoadRequest.
If I understood correctly, then as an option..
We block the redirect in BeforeResourceLoad, and then open the redirect link again with the desired redirect.
When the link in Before ResourceLoad is blocked, the resource\site will not determine this.

But you probably need to wait for the site to fully load, if it's through a proxy. if not, then how did you catch the link to make CloseAllConnections and make a new download of a new link\redirect with the necessary referrer, cookies and so on will remain the same.
Post Reply