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.
Unable to set referer
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Unable to set referer
Буду очень благодарен, если поделитесь ссылкой. Не могу найти и всё...
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Unable to set referer
OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
https://github.com/salvadordf/OldCEF4Delphi
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Unable to set referer
I have installed this component and now there are too many errors and no documentation.salvadordf wrote: Sat Aug 22, 2020 3:05 pm OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
For example, I have varables
Code: Select all
map: ICefStringMultimap
Request: ICefRequest;
Header: ICefStringMultimap;
Code: Select all
map := ICefStringMultimapOwn.Create;
Request := TCefRequestRef.New;
Header := TCefStringMultimapOwn.Create;
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Unable to set referer
Also
Code: Select all
CefSingleProcess
CefUserAgent
CefLocale
CefUserDataPath
CefCache
CefAcceptLanguageList:='ru';
TCefCookieManagerRef.Global(CefBack);
.SetStoragePath(CookiesPath, True, CefBack);
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Unable to set referer
Now you can use the TChromium.CustomHeaderName and TChromium.CustomHeaderValue properties to set HTTP headers easily.andreykrasnodar wrote: Sun Aug 23, 2020 8:59 amI have installed this component and now there are too many errors and no documentation.salvadordf wrote: Sat Aug 22, 2020 3:05 pm OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
For example, I have varables, in cef3 I wroteCode: Select all
map: ICefStringMultimap Request: ICefRequest; Header: ICefStringMultimap;
What is now?Code: Select all
map := ICefStringMultimapOwn.Create; Request := TCefRequestRef.New; Header := TCefStringMultimapOwn.Create;
Here you have an example in case you still want to do it manually :
https://github.com/salvadordf/OldCEF4De ... .pas#L3179
Many of those variables are now properties of GlobalCEFApp.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);
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.
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Unable to set referer
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.
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.
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Unable to set referer
Great! It works. Thanks.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.
I have compiled my project with no errors, but... it crashes after creating... Damn.
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Unable to set referer
I did it! Now it works with CEF4Delphi.
But I still can not send request.
cases an error
In earlier version I used
New version does not contain TCefRequestRef
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);
I think because request is not created.Access violation at address 006AF59D in module 'browser.exe'. Read of address 00000000.
In earlier version I used
Code: Select all
Request := TCefRequestRef.New;
Re: Unable to set referer
Ищи в отдельных модулях, uCEFRequest