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.
Accept-Language I can't change it.
Accept-Language I can't change it.
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?
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.
GlobalCEFApp.ChromeRuntime := True;
It doesn't respond when turned on.
It doesn't respond when turned on.
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Accept-Language I can't change it.
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.
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.
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.
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.
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Accept-Language I can't change it.
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 :
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.
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;
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.
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.
https://ibb.co/k0NgJbX
accept-encoding: gzip, deflate, br
"br" < I want to delete this too br
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.
https://ibb.co/k0NgJbX
accept-encoding: gzip, deflate, br
"br" < I want to delete this too br
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Accept-Language I can't change it.
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 :
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
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;
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.
GlobalCEFApp.ChromeRuntime:=True;
There is still no way to change it when it is turned on, right?
There is still no way to change it when it is turned on, right?
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Accept-Language I can't change it.
The chrome runtime still has some issues.
Add this code line before the GlobalCEFApp.StartMainProcess call in the DPR file :
Add this code line before the GlobalCEFApp.StartMainProcess call in the DPR file :
Code: Select all
GlobalCEFApp.AcceptLanguageList := 'ko-KR,ko';
Re: Accept-Language I can't change it.
Chromium1BeforeResourceLoad
How do I change the Referer?
map := TCefStringMultimapOwn.Create;
try
request.GetHeaderMap(map);
map.Append(Referer', 'https://google.com');
request.SetHeaderMap(map);
finally
map := nil;
end;
It doesn't change.
I would like to change the ripper part by checking if a specific URL.
How do I change the Referer?
map := TCefStringMultimapOwn.Create;
try
request.GetHeaderMap(map);
map.Append(Referer', 'https://google.com');
request.SetHeaderMap(map);
finally
map := nil;
end;
It doesn't change.
I would like to change the ripper part by checking if a specific URL.