Custom error page: how to check if an HTTP response with 4xx/5xx has a body, and thus an error page is not needed?
-
So, we want to have a custom error page in our QML-based application. The error page should show up, among other situations, when the HTTP response is in 4xx or 5xx range and the response is empty, as otherwise we'll occlude the web content. For example, going to https://gstatic.com/nothing, despite returning 404, should show Google's returned error page instead of our own.
Now, currently the only way to know if there's an error in loading or not is to listen to
WebEngineView
'sloadingChanged
, and then read theloadRequest
argument. That variable doesn't distinguish between these 2 cases and, in QtWebEngine 5.15.3+, would just say that the page load fails. I've tried looking into both QtWebEngine 5.15 and 6.3'sWebEngineView
APIs, but I cannot find something that would help in this case.So, in case I overlooked something, is there a way to implement this in QtWebEngine?