PDA

View Full Version : [SOLVED] RESTful DELETE request without entity body



facorreia
29 Jun 2010, 9:39 AM
Using a RESTful store, how can I prevent the DELETE method from sending an entity body? Currently Ext is sending the record id in JSON format, but this is both redundant (because the resource ID is specified in the URL) and problematic (because this is not the canonical form of a RESTful DELETE request, and at least the Google App Engine web server won't allow requests in this format).

I'm using by reference the sample application:

http://www.sencha.com/deploy/dev/examples/restful/restful.html

This is how the store is defined:


var store = new Ext.data.Store({
id: 'user',
restful: true, // <-- This Store is RESTful
proxy: proxy,
reader: reader,
writer: writer
});

After pressing the "Delete" button, this is the request Ext JS sends:


DELETE http://www.sencha.com/deploy/dev/examples/restful/app.php/users/6 HTTP/1.1
Host: www.sencha.com
User-Agent: Mozilla/5.0 etc.
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/json; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://www.sencha.com/deploy/dev/examples/restful/restful.html
Content-Length: 10
Cookie: bb_; etc.

{"data":6}

Notice the Content-Length header and the {"data":6} body.

When a request in this format (with the "data" content) is submitted to Google App Engine, it replies with:


400 Bad Request

So my question is, how can I prevent this entity body from being sent in DELETE requests, while still using a RESTful store?

facorreia
1 Jul 2010, 9:58 AM
Can anyone shed some light on how to make the behavior of RESTful delete on Ext JS more conformant?

facorreia
12 Jul 2010, 5:04 AM
Solved by a user on StackOverflow (http://stackoverflow.com/questions/3119179/how-can-i-prevent-ext-js-from-including-an-entity-body-in-delete-requests-using-a/3196990#3196990).