Hi,

> The problem is not the qx.io.request.Json but the fact we are trying
> to use the qx.io.rest.Resource wrapper:
> http://demo.qooxdoo.org/devel/apiviewer/#qx.io.rest.Resource

okay, I just wanted to check this first before digging deeper.

Thanks, you spotted a blind spot (i.e. bug) here, which I fixed now. :)

So this works now with the current master (not yet in the devel playground):

ml_9july.Application.js
-----------------------
var d = {
   "get": { method: "GET", url: "/" }
};
var r = new ml_9july.Resource(d);
r.setBaseUrl("http://ip.jsontest.com";);

r.addListener("getSuccess", function(e) {
   console.log("s", e.getData());
});
r.addListener("getError", function(e) {
   console.log("e", e.getData());
});
r.get();


ml_9july.Resource.js
--------------------
qx.Class.define("ml_9july.Resource",
{
   extend : qx.io.rest.Resource,

   members :
   {
     _getRequest: function() {
       return new qx.io.request.Jsonp();
     }
   }
});

> We are expecting json with multiple verbs (both GET and POST, even
> some DELETE).

Please bear in mind that JSONP is a hack/workaround - and CORS is the 
standard approach. I'm quoting Tristan, a former core developer, here:

"You can use rest.Resource with io.request.Jsonp by sub classing and 
overriding _getRequest(). The problem with JSONP, however, is that you 
always send GET requests in terms of HTTP. This is because JSONP works 
by adding a script tag pointing to the resource. Script tags cause a GET 
request. Also, there is no reliable way to send large amounts of data 
and no custom headers can be set.

In theory, its possible to emulate REST with JSONP, sending method and 
headers as part of the payload. But this requires custom modifications 
of the backend. In short, using io.request.Xhr is very much recommended. 
For browsers not supporting CORS you can try one of the polyfills 
floating around lately (adding fallbacks to qooxdoo is already planned)."

http://qooxdoo.678.n2.nabble.com/REST-CORS-td7461414.html#a7470381

So the general drawbacks are:
   - only GET requests (regarding your GET, POST, DELETE requirement)
   - no custom headers
   - no large amounts of data

Regarding qooxdoo we are only allowing GET requests when REST is used in 
combination with JSONP. You get now an error if you try to invoke a 
non-GET method:

Uncaught Error: Request (qx.io.request.Jsonp) doesn't support other HTTP 
methods than 'GET'

If you want to use JSONP and REST anyway: Here is a starting point, for 
the compromises you have to make and what you can do about them:

http://stackoverflow.com/questions/2943103/jsonp-implications-with-true-rest

Hope that helps.

Regards
Richard

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to