Page 1 of 1

Accept-Language I can't change it.

Posted: Sat Apr 27, 2024 2:00 am
by sodlf159
ICefRequest POST > Chromium1.LoadRequest(TempRequest); >

The first request changes, but

In the case of GET and POST, which are rendered the second time, there is no change.

Chromium1BeforeResourceLoad

request.SetHeaderByName('Accept-Language', 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',True);

It's the same even if you do it.

map := TCefStringMultimapOwn.Create;
try
request.GetHeaderMap(map);
map.Append('Accept-Language', 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7');
request.SetHeaderMap(map);
finally
map := nil;
end;

Even so, it doesn't change.
What is the reason?

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

Posted: Sat Apr 27, 2024 2:53 am
by sodlf159
GlobalCEFApp.ChromeRuntime := True;
It doesn't respond when turned on.

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

Posted: Sat Apr 27, 2024 2:41 pm
by salvadordf
If I remember correctly, Chromium doesn't allow to change some headers in certain events.

Try setting GlobalCEFApp.AcceptLanguageList before the GlobalCEFApp.StartMainProcess or set TChromiumCore.AcceptLanguageList for each browser.

If you set TChromiumCore.AcceptLanguageList then call TChromiumCore.UpdatePreferences to update the preferences immediately.

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

Posted: Sun Apr 28, 2024 12:43 pm
by sodlf159
TempElement := TCefPostDataElementRef.New;
TempElement.SetToBytes(length(TempParams), @TempParams[1]);
TempPostData := TCefPostDataRef.New;
TempPostData.AddElement(TempElement);

TempRequest.PostData := TempPostData;
Chromium1.AcceptLanguageList := 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7';
Chromium1.UpdatePreferences;
Chromium1.LoadRequest(TempRequest);

It seems like it can't be changed.

GlobalCEFApp.AcceptLanguageList := 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7';

GlobalCEFApp.ChromeRuntime := True;
if GlobalCEFApp.StartMainProcess then
Even so, there is no response.

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

Posted: Mon Apr 29, 2024 8:26 am
by salvadordf
I did several tests with GlobalCEFApp.AcceptLanguageList and also setting TChromiumCore.AcceptLanguageList in TChromiumCore.OnAfterCreated.

The MiniBrowser demo shows the custom Accept-Language value when you visit and in the "Show server headers" context menu option.

It's also possible to see the HTML headers that the browser is using when you navigate to :
https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending

I also added a custom menu item with this code :

Code: Select all

procedure TMiniBrowserFrm.LoadRequest1Click(Sender: TObject);
var
  Request: ICefRequest;
begin
  Request := TCefRequestRef.New;
  Request.Url := 'https://www.briskbard.com/images/logo.png';
  Request.Method := 'GET';

  Chromium1.LoadRequest(Request);
end;
The "Show server headers" context menu option also showed the custom Accept-Language value after loading that request.

TChromiumCore.UpdatePreferences is asynchronous but the preferences are automatically updated internally in the TChromiumCore.OnBeforeBrowse

The code comments for TChromiumCore.LoadResource mention that this function will fail with bad IPC message reason INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the request origin using some other mechanism (LoadURL, link click, etc).

Try setting the GlobalCEFApp.AcceptLanguageList value, then navigate to the same domain using TChromiumCore.LoadURL and after that you can call TChromiumCore.LoadResource safely.

Accept-Language I can't change it.

Posted: Thu May 16, 2024 4:21 pm
by sodlf159
https://www.briskbard.com/forum/viewtopic.php?t=2289&sid=aefe847efd406ee071e79a18275382d3

It comes out as a duplicate together with the existing one.

ko-KR","ko;q=0.9","en-US;q=0.8","en;q=0.7

F12
accept-language: ko-KR,ko;q=0.9,ko;q=0.9;q=0.8,en-US;q=0.8;q=0.7,en;q=0.6,en;q=0.7;q=0.5

"en;q=0.6,en;q=0.7;q=0.5" << default I want to delete this.

Image

https://ibb.co/k0NgJbX

accept-encoding: gzip, deflate, br

"br" < I want to delete this too br

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

Posted: Fri May 17, 2024 8:51 am
by salvadordf
I merged the forum topics.

In order to solve the issue with the Accept-Language header replace the TMiniBrowserFrm.Chromium1AfterCreated procedure in MiniBrowser with this :

Code: Select all

procedure TMiniBrowserFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
  Chromium1.AcceptLanguageList := 'ko-KR,ko';

  if Chromium1.IsSameBrowser(browser) then
    PostMessage(Handle, CEF_AFTERCREATED, 0, 0)
   else
    SendMessage(browser.Host.WindowHandle, WM_SETICON, 1, application.Icon.Handle); // Use the same icon in the popup window
end;
With that fix browserleaks.com shows "ko-KR,ko;q=0.9" in the Accept-Language header.

I searched about the Accept-Encoding header and I found this CEF issue :
https://github.com/chromiumembedded/cef/issues/2303

The Brotli encoding should be working in CEF browsers.

I also found this old support answer about disabling it in Chrome :
https://support.google.com/websearch/thread/13460143/how-do-i-disable-brotli-content-encoding-in-chrome-ver-76-0-3809-100?hl=en

I would try replacing the Accept-Encoding HTTP header in the TChromium.OnBeforeResourceLoad event like this :
https://github.com/salvadordf/CEF4Delphi/blob/5ae265e9d3ce7076bda56c6429a642d5c76b83ef/source/uCEFChromiumCore.pas#L8308

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

Posted: Fri May 17, 2024 8:09 pm
by sodlf159
GlobalCEFApp.ChromeRuntime:=True;

There is still no way to change it when it is turned on, right?

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

Posted: Sat May 18, 2024 12:13 pm
by salvadordf
The chrome runtime still has some issues.

Add this code line before the GlobalCEFApp.StartMainProcess call in the DPR file :

Code: Select all

GlobalCEFApp.AcceptLanguageList := 'ko-KR,ko';