How to handle empty HTTP response

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to handle empty HTTP response

Postby rado » Thu Nov 01, 2018 1:33 pm

When server returns some error HTTP response with empty body, the Chrome shows error message.
The cefclient shows empty page so user does not know what's going on.
Here is example: http://www.mocky.io/v2/5bdb41c3320000b6293ad50d.
How can I handle this and show error message? My idea was to use OnResourceResponse() where I can check response status and redirect to error page, but I'm afraid I cannot check if body is empty at that handler. Is it possible or is there some better way? My second idea is to use CefResponseFilter but it seems to bit complicated for simple task, maybe is there some simpler way?
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: How to handle empty HTTP response

Postby Czarek » Mon Nov 05, 2018 1:34 pm

In CefRequestHandler::OnResourceLoadComplete call frame->GetText().
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: How to handle empty HTTP response

Postby rado » Fri Nov 30, 2018 8:39 am

Czarek wrote:In CefRequestHandler::OnResourceLoadComplete call frame->GetText().

It seems it returns empty string even when response body is not empty so error handler would always show default error message.
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], linuxcef07, Majestic-12 [Bot] and 86 guests