Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestURI: failure callback/hook not invoked when used with a proxy #27

Open
slorber opened this issue Jan 24, 2014 · 1 comment
Open

Comments

@slorber
Copy link
Contributor

slorber commented Jan 24, 2014

Hi.

When using requestURI, it is not always possible to know that there were a failure.

https://github.com/linkeddata/rdflib.js/blob/master/web.js#L1016

// Setup the request
        if (typeof jQuery !== 'undefined' && jQuery.ajax) {
            var xhr = jQuery.ajax({
                url: uri2,
                accepts: {'*': 'text/turtle,text/n3,application/rdf+xml'},
                processData: false,
                error: function(xhr, s, e) {
                    if (s == 'timeout')
                        sf.failFetch(xhr, "requestTimeout");
                    else
                        onerrorFactory(xhr)(e);
                },
                success: function(d, s, xhr) {
                    onreadystatechangeFactory(xhr)();
                }
            });
        } else {
            var xhr = $rdf.Util.XMLHTTPFactory();
            xhr.onerror = onerrorFactory(xhr);
            xhr.onreadystatechange = onreadystatechangeFactory(xhr);
            try {
                xhr.open('GET', uri2, this.async);
            } catch (er) {
                return this.failFetch(xhr, "XHR open for GET failed for <"+uri2+">:\n\t" + er);
            }
        }

With JQuery + usage of a proxy, the onreadystatechangeFactory will not fire the failFetch method which triggers the fail callback hook.

        var onerrorFactory = function(xhr) { return function(event) {
            if ($rdf.Fetcher.crossSiteProxyTemplate && document && document.location && !xhr.proxyUsed) { // In mashup situation
                 //


                 // NEVER CALLED: sf.failFetch(xhr, "XHR Error: "+event)
                 // But it seems to re-do the request again but 

               //
            } else {
                sf.failFetch(xhr, "XHR Error: "+event)
            }
        }; }

https://github.com/linkeddata/rdflib.js/blob/master/web.js#L693

As expected, the fail hook is correctly triggered when there is a no proxy.

So, when using this method with a proxy, there is no way to know that the request has terminated.

@slorber
Copy link
Contributor Author

slorber commented Jan 24, 2014

I think the default RDFLib behavior is to try to fetch the resource without the proxy and if there is an error, try too fetch the resource with the proxy.
I see 2 requestURI calls being triggered but no callback is invoked for the later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant