Yes, i think there are some missing use-cases for qx.io.request.Xhr.

Whith the following code:

var req = new qx.io.request.Xhr("/rpc", "POST");
req.setRequestHeaders({ "Content-Type": "application/json" });
req.setRequestData({ "title": "The title" });
req.send();

I expect to generate a request with:

content type: "application/json"
body text: { "title": "The title" }

Instead, what i obtain is a request with:

content type: "application/x-www-form-urlencoded, application/json"
body text (form encoded): title="The title"

Seems to me that qx.io.request.Xhr is developed with only form post
request encoding in mind.
The problem is that there isn't really a workaround to send a JSON
encoded request using qx.io.request.Xhr.


Gian Marco Gherardi
http://gianmarco.gherardi.me



On Thu, Jul 21, 2011 at 1:24 PM, Alexander Steitz
<[email protected]> wrote:
> Hi Gian Marco,
>
> On Thursday 21 July 2011 12:06:25 Gian Marco Gherardi wrote:
>> Yes i've used it, this is what i've tried:
>>
>> var req = new qx.io.request.Xhr("/rpc", "POST");
>> req.setRequestData({ "title": "The title" });
>> req.send(); // send request data as form encoded, with content type
>> "application/x-www-form-urlencoded"
>>
>> var req = new qx.io.request.Xhr("/rpc", "POST");
>> req.setRequestHeaders({ "Content-Type": "application/json" });
>> req.setRequestData({ "title": "The title" });
>> req.send(); // send request data as form encoded, with content type
>> "application/x-www-form-urlencoded, application/json"
>>
>> var req = new qx.io.request.Xhr("/rpc", "POST");
>> req.setRequestHeaders({ "Content-Type": "application/json" });
>> req.setRequestDataqx.lang.Json.stringify({ "title": "The title" }));
>> req.send(); // send request data as json encoded, with content type
>> "application/x-www-form-urlencoded, application/json"
>>
>> So, none of the example work as i need. I think that, with
>> qx.io.request in 1.5, is not possible to achieve what i need.
> For your information: The content type "application/json" is set automatically
> when you set method to "POST".
>
> So what should be send over the wire? It has to be serialized into a string
> for the native Xhr object - even if you set JSON as data in the high level
> implementation.
>
> Feel free to open an enhancement issue if I misunderstood / overlooked
> something here. Maybe there is an usecase we missed and that would be good to
> know.
>
> Regards,
>  Alex
>
> ------------------------------------------------------------------------------
> 5 Ways to Improve & Secure Unified Communications
> Unified Communications promises greater efficiencies for business. UC can
> improve internal communications as well as offer faster, more efficient ways
> to interact with customers and streamline customer service. Learn more!
> http://www.accelacomm.com/jaw/sfnl/114/51426253/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>

------------------------------------------------------------------------------
5 Ways to Improve & Secure Unified Communications
Unified Communications promises greater efficiencies for business. UC can 
improve internal communications as well as offer faster, more efficient ways
to interact with customers and streamline customer service. Learn more!
http://www.accelacomm.com/jaw/sfnl/114/51426253/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to