Change the response status code


#1

Hi,

I was wondering on how I should go about changing the response status code using a script.
Let us say I want to reply with a code 403 or 402 or a 400, how should I do that?

I have tried to set:

event.response.code = 403;

But it seems to still send a 200 OK with a JSON

{"code":403}

I want to change the status code in the response itself instead.

Thanks!


#2

Currently, the status code is dictated by the response handler, which scripting cannot modify. However we have included this as a new feature to be available in 2.0.


#3

That will be a useful addition. Currently actionscript 3 cannot read the http response body for anything other than a 200 success response.

The work around is to return a 200 even for an error and parse the error message from the body. Which is obviously a horrible, retarded hack…

http://stackoverflow.com/questions/23660882/how-to-access-http-response-body-on-failure


#4

Hi Jeffrey,

With the new version out, is now possible to change the status code?
I’ve searched in the documentation but there is no trace of it.

Thanks
Gabriel