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.

Unable to set referer

Student
Posts: 73
Joined: Tue Aug 07, 2018 9:20 am

Re: Unable to set referer

Post by Student »

2623
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Unable to set referer

Post by andreykrasnodar »

Student wrote: Sat Aug 22, 2020 12:10 pm2623
Буду очень благодарен, если поделитесь ссылкой. Не могу найти и всё...
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Unable to set referer

Post by salvadordf »

OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Unable to set referer

Post by andreykrasnodar »

salvadordf wrote: Sat Aug 22, 2020 3:05 pm OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
I have installed this component and now there are too many errors and no documentation.
For example, I have varables

Code: Select all

map: ICefStringMultimap
Request: ICefRequest;
Header: ICefStringMultimap;
, in cef3 I wrote

Code: Select all

  map := ICefStringMultimapOwn.Create;
  Request := TCefRequestRef.New;
  Header := TCefStringMultimapOwn.Create;
What is now?
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Unable to set referer

Post by andreykrasnodar »

Also

Code: Select all

CefSingleProcess
CefUserAgent
CefLocale
CefUserDataPath
CefCache
CefAcceptLanguageList:='ru';
TCefCookieManagerRef.Global(CefBack);
.SetStoragePath(CookiesPath, True, CefBack);
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Unable to set referer

Post by salvadordf »

andreykrasnodar wrote: Sun Aug 23, 2020 8:59 am
salvadordf wrote: Sat Aug 22, 2020 3:05 pm OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
I have installed this component and now there are too many errors and no documentation.
For example, I have varables

Code: Select all

map: ICefStringMultimap
Request: ICefRequest;
Header: ICefStringMultimap;
, in cef3 I wrote

Code: Select all

  map := ICefStringMultimapOwn.Create;
  Request := TCefRequestRef.New;
  Header := TCefStringMultimapOwn.Create;
What is now?
Now you can use the TChromium.CustomHeaderName and TChromium.CustomHeaderValue properties to set HTTP headers easily.

Here you have an example in case you still want to do it manually :
https://github.com/salvadordf/OldCEF4De ... .pas#L3179
andreykrasnodar wrote: Sun Aug 23, 2020 9:18 am Also

Code: Select all

CefSingleProcess
CefUserAgent
CefLocale
CefUserDataPath
CefCache
CefAcceptLanguageList:='ru';
TCefCookieManagerRef.Global(CefBack);
.SetStoragePath(CookiesPath, True, CefBack);
Many of those variables are now properties of GlobalCEFApp.

Use GlobalCEFApp.SingleProcess, GlobalCEFApp.UserAgent, GlobalCEFApp.Locale, GlobalCEFApp.UserDataPath, GlobalCEFApp.Cache, GlobalCEFApp.AcceptLanguageList, GlobalCEFApp.Cookies, etc.

Read this page :
https://www.briskbard.com/index.php?lang=en&pageid=cef

Most of that information is still relevant to the OldCEF4Delphi component. Also, open the SimpleBrowser and SimpleBrowser2 demos and read the code comments.

I would suggest that you take a look at the demos and pick one that is similar to what you need. Then use it as a template for your application.
If your application uses the OSR mode then perhaps you should use the SimpleOSRBrowser demo.

Be careful with the GlobalCEFApp.SingleProcess property. That mode is NOT supported by CEF and it's a known cause of issues. You should only use it for debugging purposes.
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Unable to set referer

Post by salvadordf »

One more thing.

OldCEF4Delphi and CEF4Delphi use the recomended settings to initialize CEF.

That means that by default you use the "multithread message loop" (known as CEF_MULTI_THREADED_MESSAGE_LOOP in dcef3) and most of the TChromium and GlobalCEFApp events are executed in a CEF thread.

As you know, VCL is not thread safe and you should not create, destroy or modify VCL controls inside those events. The demos are oversimplified and they still modify controls inside those events but you should move that code to the main application thread.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Unable to set referer

Post by andreykrasnodar »

salvadordf wrote: Sun Aug 23, 2020 9:30 am Many of those variables are now properties of GlobalCEFApp.

Use GlobalCEFApp.SingleProcess, GlobalCEFApp.UserAgent, GlobalCEFApp.Locale, GlobalCEFApp.UserDataPath, GlobalCEFApp.Cache, GlobalCEFApp.AcceptLanguageList, GlobalCEFApp.Cookies, etc.
Great! It works. Thanks.
I have compiled my project with no errors, but... it crashes after creating... Damn.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Unable to set referer

Post by andreykrasnodar »

I did it! Now it works with CEF4Delphi.
But I still can not send request.

Code: Select all

  Request.Url:='https://google.com';
  request.Method:='GET';
  request.SetReferrer('https://yahoo.com',REFERRER_POLICY_DEFAULT);
  chromium2.Browser.MainFrame.LoadRequest(Request);
cases an error
Access violation at address 006AF59D in module 'browser.exe'. Read of address 00000000.
I think because request is not created.
In earlier version I used

Code: Select all

Request := TCefRequestRef.New;
New version does not contain TCefRequestRef
Student
Posts: 73
Joined: Tue Aug 07, 2018 9:20 am

Re: Unable to set referer

Post by Student »

Ищи в отдельных модулях, uCEFRequest
Post Reply