XHR gets "canceled"

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.

XHR gets "canceled"

Postby diwic » Tue Jun 12, 2018 4:59 am

So I'm not sure where to continue debugging this. A custom scheme loads this simple page:

Code: Select all
<!DOCTYPE html>
<html>
  <head>
      <script>
        function do_something(data){
            var hhh = new XMLHttpRequest();
            hhh.onreadystatechange = function() {
                console.log("XHR debug: " + hhh.readyState + " status " + hhh.status);
                if(hhh.readyState === 4 && hhh.status === 200) {
                    console.log("Response: " + hhh.responseText);
                    document.getElementById("test").innerHTML = hhh.responseText;
                }
            };
            // This URL works
            hhh.open("GET", "https://code.jquery.com/jquery-3.3.1.min.js");
            // This URL doesn't work
            hhh.open("GET", "https://tools.ietf.org/html/rfc2616");
            hhh.send();
        }
      </script>
  </head>
  <body onload="do_something()">
      <div id="test"></div>
  </body>
</html>


When an URL does not work, it ends up with status "canceled" in OnResourceLoadComplete. And that's all I know, really, I see no other signs of error (having looked in, e g console log and OnLoadError). I think - but I'm not totally sure - that some URL would fail on one computer and succeed on another computer, suggesting this could be some timing or network issue...?

As for CORS, the custom scheme is registered with
Code: Select all
AddCustomScheme(SchemeName, False, False, False, False, False, True)

so CORS should not interfere here. I've also tried disabling web security, which makes no difference.

I'm using v3.3282.1741 and a matching Cef4Delphi, if that matters. Thankful for any hints on how to continue debugging this problem.
diwic
Newbie
 
Posts: 7
Joined: Tue Mar 06, 2018 11:15 am

Re: XHR gets "canceled"

Postby salvadordf » Tue Jun 12, 2018 5:29 am

Hi,

This is not the CEF4Delphi support forum. Please, use this forum :
https://www.briskbard.com/forum
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects.
User avatar
salvadordf
Expert
 
Posts: 129
Joined: Sun Dec 18, 2016 8:39 am
Location: Spain

Re: XHR gets "canceled"

Postby ndesktop » Wed Jun 13, 2018 12:22 am

1. What is the output of console.log?
2. If you try this with cefclient (you might need to modify and build cefclient it yourself, or ask someone with a C++ dev environment already set up), does it work correctly?
ndesktop
Master
 
Posts: 754
Joined: Thu Dec 03, 2015 10:10 am

Re: XHR gets "canceled"

Postby diwic » Wed Jun 13, 2018 5:55 am

ndesktop wrote:1. What is the output of console.log?
2. If you try this with cefclient (you might need to modify and build cefclient it yourself, or ask someone with a C++ dev environment already set up), does it work correctly?


The output of console.log is:

Code: Select all
XHR debug: 1 status 0
XHR debug: 2 status 200
XHR debug: 4 status 200
Response:


I can also see headers (that look correct) in OnResourceLoadComplete. It's like I only get the headers, but the content is empty.

For 2. This would require, I assume, me porting a lot of code to C++, which is something I hope to avoid at this point, but maybe it is necessary...
diwic
Newbie
 
Posts: 7
Joined: Tue Mar 06, 2018 11:15 am

Re: XHR gets "canceled"

Postby ndesktop » Wed Jun 13, 2018 6:58 am

Well, there is a CORS extension (CORS Toggle, ID: omcncfnpmcabckcddookmnajignpffnh) for Chrome.
Can you try to check if Chrome gives you the same error?
ndesktop
Master
 
Posts: 754
Joined: Thu Dec 03, 2015 10:10 am

Re: XHR gets "canceled"

Postby diwic » Wed Jun 13, 2018 7:44 am

ndesktop wrote:Well, there is a CORS extension (CORS Toggle, ID: omcncfnpmcabckcddookmnajignpffnh) for Chrome.
Can you try to check if Chrome gives you the same error?


It seems to work well with the "file:///" protocol, both in Chrome with CORS Toggle, and in my application. It is only when the custom scheme is serving the page that the problem appears, and AFAIK, I can't add custom schemes to Chrome, right?

Unless it's a timing issue and changing "custom scheme" to "file" just changes the timing slightly so that the problem does no longer appear on this particular computer...
diwic
Newbie
 
Posts: 7
Joined: Tue Mar 06, 2018 11:15 am

Re: XHR gets "canceled"

Postby magreenblatt » Wed Jun 13, 2018 10:52 am

You can use your custom handler with the HTTP/HTTPS scheme instead of a custom scheme.
magreenblatt
Site Admin
 
Posts: 12402
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 39 guests