Page 2 of 2
Re: Accept-Language I can't change it.
Posted: Fri May 31, 2024 1:23 pm
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.
Re: Accept-Language I can't change it.
Posted: Fri May 31, 2024 2:51 pm
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.
Re: Accept-Language I can't change it.
Posted: Sat Jun 01, 2024 10:06 am
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
Re: Accept-Language I can't change it.
Posted: Mon Jun 03, 2024 8:01 am
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
Re: Accept-Language I can't change it.
Posted: Mon Jun 03, 2024 10:10 am
by sodlf159
That's not the way.
I would like to change the referrer to a specific URL that is redirected to LoadRequest.
Re: Accept-Language I can't change it.
Posted: Mon Jun 03, 2024 3:45 pm
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.