PDA

View Full Version : setting content-type=application/json in JSONWriter DELETE?



frif
7 Nov 2009, 1:10 AM
Hello,

Question: How can force the content type to be application/json for the DELETE requests sent by JSONStore?

I've been looking at the examples at extjs own web site, like

http://www.extjs.com/deploy/dev/examples/restful/restful.html
http://www.extjs.com/deploy/dev/examples/writer/writer.html

The DELETEs sent to the server by JSONWriter have content-type application/x-www-form-urlencoded, instead of application/json

POST and PUT however have content-type=application/json

I understand that the DELETE packets don't contain any data, so it seems there is no need to put the content-type=application/json. However my server
automatically serializes the response according to the content-type of the request, therefore I need to have the right content-type for the DELETE requests as well.

Thanks
frif

I'm using the Catalyst Framework (perl 5)

frif
7 Nov 2009, 2:14 AM
Solved. I found the answer in this thread:

http://www.extjs.com/forum/showthread.php?t=72362&page=2

I just needed to set the headers in the HttpProxy of the store that uses the JsonWriter. It's configuration object is like this:



{
url: '/rest/users',
// Ask for Json response
headers: { 'Content-Type': 'application/json;charset=utf-8' }
}