Page 1 of 1

Strange user-agent and <A> attribute "ping".

Posted: Wed Jul 15, 2020 8:05 am
by igor666
I apologize for asking 2 questions, I did not want to produce extra topics.

1. I set my AcceptLanguageList

Code: Select all

GlobalCEFApp.AcceptLanguageList: = 'ru-RU, ru; q = 0.9, en-US; q = 0.8, en; q = 0.7';
but as a result, I see the following in the developer’s tools

Code: Select all

Accept-Language: ru-RU, ru; q = 0.9, ru; 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
Why is that? The AcceptLanguageList that I install is the standard LanguageList for my region, as it is in the Chrome browser.

2.The second question concerns the attribute ping tag A, it does not make a request. You can check on Google search. When you click on the link from the search result, a request should be sent to the address specified in the ping attribute, but this request is not in the developer tools. Although it is in the same Google browser. Below are screenshots, on the first request from the Chrome browser, the cursor is placed just on the request from the ping attribute. On the second, the same transition to cef4, there is no request. Can this be fixed?

Thanks for the help!

Re: Strange user-agent and <A> attribute "ping".

Posted: Wed Jul 15, 2020 8:34 am
by salvadordf
igor666 wrote: Wed Jul 15, 2020 8:05 am 1. I set my AcceptLanguageList

Code: Select all

GlobalCEFApp.AcceptLanguageList: = 'ru-RU, ru; q = 0.9, en-US; q = 0.8, en; q = 0.7';
but as a result, I see the following in the developer’s tools

Code: Select all

Accept-Language: ru-RU, ru; q = 0.9, ru; 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
Why is that? The AcceptLanguageList that I install is the standard LanguageList for my region, as it is in the Chrome browser.
There are several properties to assign the AcceptLanguageList. Try a different property if you see Chromium is modifying your list :
  • GlobalCEFApp.AcceptLanguageList : You have to set this before the GlobalCEFApp.StartMainProcess call
  • TChromium.AcceptLanguageList : You can call this function at any time but you will have to call TChromium.UpdatePreferences after you set this property.
  • TChromium.Options.AcceptLanguageList : You have to set this property before calling TChromium.CreateBrowser
  • TChromium.SetUserAgentOverride(const aUserAgent, aAcceptLanguage, aPlatform : ustring) : You can call this function at any time.
igor666 wrote: Wed Jul 15, 2020 8:05 am 2.The second question concerns the attribute ping tag A, it does not make a request. You can check on Google search. When you click on the link from the search result, a request should be sent to the address specified in the ping attribute, but this request is not in the developer tools. Although it is in the same Google browser. Below are screenshots, on the first request from the Chrome browser, the cursor is placed just on the request from the ping attribute. On the second, the same transition to cef4, there is no request. Can this be fixed?
GlobalCEFApp.HyperlinkAuditing is TRUE by default and it adds the --no-pings switch to skip those requests. Set it to FALSE if you need them.

Re: Strange user-agent and <A> attribute "ping".

Posted: Wed Jul 15, 2020 9:33 am
by igor666
Thanks, TChromium.Options.AcceptLanguageList works.
But GlobalCEFApp.HyperlinkAuditing: = false did not help, the request is still not in the developer tools.

Re: Strange user-agent and <A> attribute "ping".

Posted: Wed Jul 15, 2020 9:58 am
by salvadordf
Sorry I was confused.

The default value of GlobalCEFApp.HyperlinkAuditing (true) should be enough to avoid setting the --no-pings switch.
The GlobalCEFApp.DisableBackgroundNetworking is FALSE by default so it shouldn't affect the pings.

I'm really busy right now but you can try disabling some sections (or all) the TCefApplicationCore.Internal_OnBeforeCommandLineProcessing procedure to see what switch is the culprit.

Re: Strange user-agent and <A> attribute "ping".

Posted: Wed Jul 15, 2020 5:44 pm
by igor666
Unfortunately nothing helped, commented everything in OnBeforeCommandLineProcessing but still no ping. I looked in your Briskbard browser, the situation is similar there.

By the way, TChromium.Options.AcceptLanguageList worked in one project, in the second much the same, it doesn’t work. I checked in MiniBrowser demo, it also does not work correctly. And when you try to interactively change the AcceptLanguageList from the property, it reads it correctly, but not when it is displayed in the developer tools.

Re: Strange user-agent and <A> attribute "ping".

Posted: Thu Jul 16, 2020 10:28 am
by salvadordf
igor666 wrote: Wed Jul 15, 2020 5:44 pm Unfortunately nothing helped, commented everything in OnBeforeCommandLineProcessing but still no ping. I looked in your Briskbard browser, the situation is similar there.
Try commenting everything in GlobalCEFApp.OnBeforeCommandLineProcessing and TChromiumCore.doUpdatePreferences

That would leave the browser with all the default CEF preferences and settings values and it should behave exactly as the official CEF sample application.
igor666 wrote: Wed Jul 15, 2020 5:44 pm By the way, TChromium.Options.AcceptLanguageList worked in one project, in the second much the same, it doesn’t work. I checked in MiniBrowser demo, it also does not work correctly. And when you try to interactively change the AcceptLanguageList from the property, it reads it correctly, but not when it is displayed in the developer tools.
The TChromium.Options.AcceptLanguageList value is used in the TChromium.CreateBrowser function and it's not used after that.
If you need to change the AcceptLanguageList after creating the browser then use TChromium.SetUserAgentOverride or TChromium.AcceptLanguageList

Re: Strange user-agent and <A> attribute "ping".

Posted: Mon Jul 20, 2020 8:34 am
by igor666
Thanks Salvador. Ping was defeated, in the procedure

Code: Select all

procedure TChromiumCore.doUpdatePreferences(const aBrowser: ICefBrowser);
begin
  FUpdatePreferences := False;

  // The preferences registered in CEF are defined in :
  // /libcef/browser/prefs/browser_prefs.cc

  UpdateProxyPrefs(aBrowser);
  UpdatePreference(aBrowser, 'enable_do_not_track',                  FDoNotTrack);
  UpdatePreference(aBrowser, 'enable_referrers',                     FSendReferrer);
  //UpdatePreference(aBrowser, 'enable_a_ping',                        FHyperlinkAuditing);
  UpdatePreference(aBrowser, 'plugins.run_all_flash_in_allow_mode',  FRunAllFlashInAllowMode);
  UpdatePreference(aBrowser, 'plugins.allow_outdated',               FAllowOutdatedPlugins);
  UpdatePreference(aBrowser, 'plugins.always_authorize',             FAlwaysAuthorizePlugins);
  UpdatePreference(aBrowser, 'browser.enable_spellchecking',         FSpellChecking);
  UpdateStringListPref(aBrowser, 'spellcheck.dictionaries',          FSpellCheckerDicts);
  UpdatePreference(aBrowser, 'settings.force_google_safesearch',     FSafeSearch);
  UpdatePreference(aBrowser, 'settings.force_youtube_restrict',      FYouTubeRestrict);
  UpdatePreference(aBrowser, 'printing.enabled',                     FPrintingEnabled);

  if (length(FAcceptLanguageList) > 0) then
    UpdatePreference(aBrowser, 'intl.accept_languages', FAcceptLanguageList);

  if (FMaxConnectionsPerProxy <> CEF_MAX_CONNECTIONS_PER_PROXY_DEFAULT_VALUE) then
    UpdatePreference(aBrowser, 'net.max_connections_per_proxy', FMaxConnectionsPerProxy);

  if FRunAllFlashInAllowMode then
    UpdatePreference(aBrowser, 'profile.default_content_setting_values.plugins', 1);

  case FWebRTCIPHandlingPolicy of
    hpDefaultPublicAndPrivateInterfaces :
      UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_and_private_interfaces');

    hpDefaultPublicInterfaceOnly :
      UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_interface_only');

    hpDisableNonProxiedUDP :
      UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'disable_non_proxied_udp');
  end;

  if (FWebRTCMultipleRoutes <> STATE_DEFAULT) then
    UpdatePreference(aBrowser, 'webrtc.multiple_routes_enabled', (FWebRTCMultipleRoutes = STATE_ENABLED));

  if (FWebRTCNonProxiedUDP <> STATE_DEFAULT) then
    UpdatePreference(aBrowser, 'webrtc.nonproxied_udp_enabled', (FWebRTCNonProxiedUDP = STATE_ENABLED));
end;
commented out the line UpdatePreference(aBrowser, 'enable_a_ping', FHyperlinkAuditing); and now everything works as it should. The variable FHyperlinkAuditing is always false here, regardless of the GlobalCEFApp.HyperlinkAuditing setting and therefore pings did not work.

Thanks again for your help.

Re: Strange user-agent and <A> attribute "ping".

Posted: Mon Jul 20, 2020 8:40 am
by salvadordf
Thanks for testing this and finding the cause of this issue! :D

I'll set the same default value for the GlobalCEFApp.HyperlinkAuditing and TChromium.HyperlinkAuditing properties in the next update.

Re: Strange user-agent and <A> attribute "ping".

Posted: Tue Jul 21, 2020 1:40 pm
by igor666
If someone is interested with the user-agent also figured out. If you do like this

Code: Select all

GlobalCEFApp.AcceptLanguageList: = 'ru-RU, ru; q = 0.9, en-US; q = 0.8, en; q = 0.7';
as a result we get this

Code: Select all

Accept-Language: ru-RU, ru; q = 0.9, ru; 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
and if you assign this value

Code: Select all

GlobalCEFApp.AcceptLanguageList: = 'ru-RU, en-US';
then the result will be the one I need

Code: Select all

GlobalCEFApp.AcceptLanguageList: = 'ru-RU, ru; q = 0.9, en-US; q = 0.8, en; q = 0.7';
CEF substitutes "q" itself, and as practice has shown, not always. Something like this :)