Vladimir Fesko
Posts: 0
Joined: Sun Oct 20, 2013 6:21 am

Server code: send correct mime type for error with json body

Hello!
Is it possible to to send correct mime type for errors in serve code?
I have to use XMLHttpRequest and forward its response to client. For error it returns good response code (like 404) and error body as JSON object:

var xhrResponse = XHR.send(..);
// xhrResponse.body is {"description":"User 'xxx' does not exist.","code":"DBUI110"}"
// xhrResponse.status is 404
response.error(xhrResponse .body, xhrResponse .status);

---

This produces response with code 404, specified body AND mime type /
Firefox says "not well formed" and doesn't work properly because it expects mime type to be "application/json" for this particular body.

How could I send correct mime type with error response? Or in general - a responce with specific body, code and headers?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Server code: send correct mime type for error with json body

Hello Vladimir!

Sorry for late response, need time to check it. We'll get back to you as soon as possible.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Server code: send correct mime type for error with json body

Hello! Sorry for delay. All responses you can send from server code are described here http://docs.appery.io/documentation/b...
Content-Type:/ doesn't affect anything. Could yo clarify what are you trying to do and what exactly doesn't work?

Vladimir Fesko
Posts: 0
Joined: Sun Oct 20, 2013 6:21 am

Server code: send correct mime type for error with json body

Actually, it was the case when I tried to test my app with Firefox and Selenium. In Firefox 24.0 and selenium ide 2.4.0 it didn't work for some reason. Maybe it wasn't direct reason but it's he thing you should mention. Your're right, it's not a big problem but a small lack of useful feature - is there any way to send desired content type with "response.error", not only with "response.success" and "response.binary" ?

Thank you!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Server code: send correct mime type for error with json body

Hello! [quote:]is there any way to send desired content type with "response.error"[/quote] No

not sure I understand when you receive error in Firefox. If you have 404 error in response result won't parse, or you parse it manually?

Return to “Issues”