This probably doesn't help, but the only way I know to manipulate the status code is to throw an exception. There are a set of default exceptions that are pointed to 400, 401, 403, 404, and 500. The docs say you can subclass endpoints.ServiceException to throw other status codes, however I couldn't get this to work. If you set http_status to anything other than one of the above, it always results in 400.
class TestException(endpoints.ServiceException): http_status = httplib.NO_CONTENT
I run the test in my handler as follows:
raise TestException('The status should be 204')
And I see this output when testing using an API browser:
400 Bad Request - Show headers - { "error": { "errors": [ { "domain": "global", "reason": "badRequest", "message": "The status should be 204" } ], "code": 400, "message": "The status should be 204" } }
source share