How to change status code for response?

How can I can change the status code for a response?
For example when requesting an invalid ressource I want to return 404.
I just found some error related stuff for async calls

Edit: Ok I look into the source and it seems this options is not given... so I added it :)