Page 1 of 1

How to get HTTP response code ?

Posted: Fri Oct 28, 2022 1:25 pm
by thefunkyjoint
I'm having an issue where when i try to navigate to a specific page inside CEF4Delphi, the page won't open, will keep blank.

But if i navigate to the same page with Chrome, it will show a HTTP ERROR 429.

How can i know in CEF4Delphi, that a HTTP 429 is returned ? Looks like CEF4Delphi won't show the http error code, like Chrome does.

Re: How to get HTTP response code ?

Posted: Fri Oct 28, 2022 5:41 pm
by salvadordf
Hi,

The TChromium.OnLoadError event should be triggered and the "errorCode" parameter should have a -429 value.

Check that the TChromium.OnRenderProcessTerminated event is not triggered. :?

Re: How to get HTTP response code ?

Posted: Sat Oct 29, 2022 5:22 pm
by thefunkyjoint
I tested with this simulation url :

http://httpstat.us/429

But somehow, the onLoadError event is not triggered :roll:

Re: How to get HTTP response code ?

Posted: Sat Oct 29, 2022 10:17 pm
by Student
I also do not respond to this error in the onLoadError. But as an alternative solution, you can use the event OnLoadEnd, there is httpStatusCode and track any error code and display information to the user.

Re: How to get HTTP response code ?

Posted: Sun Oct 30, 2022 12:45 pm
by thefunkyjoint
Student wrote: Sat Oct 29, 2022 10:17 pm I also do not respond to this error in the onLoadError. But as an alternative solution, you can use the event OnLoadEnd, there is httpStatusCode and track any error code and display information to the user.
Thank you, this worked ! :D

Re: How to get HTTP response code ?

Posted: Fri Nov 04, 2022 6:58 am
by dilfich
Wouldn't it be more correct to check in ResourceLoadComplete, I always look at the download status of a particular link there.

Re: How to get HTTP response code ?

Posted: Fri Nov 04, 2022 10:57 am
by Student
dilfich wrote: Fri Nov 04, 2022 6:58 am Wouldn't it be more correct to check in ResourceLoadComplete, I always look at the download status of a particular link there.
I think it depends on the need, if you want to check each resource then ResourceLoadComplete, if only loading the entire page then OnLoadEnd.
Don't forget that ResourceLoadComplete is triggered on every resource load, if you have too many resources on your site, your code will be executed often and performance will go down.