Does anyone know how to manipulate the HTTP Status text in Scala Play 2.2? I see that it's easy to specify the status code but not the accompanying text.
The reason I'm interested is that I'm trying to emulate exactly a web service I need to consume, and it puts specific information in the status text.
For example, when failing a login attempt I'll get the following snippet from this service (curl output):
< HTTP/1.1 401 username or password invalid
< ...
When I return an Unauthorized response from my Mock service I just get the following:
< HTTP/1.1 401 Unauthorized
< ...
I'm clearly missing the real way to do this if it's even possible in the first place.
Here's how I'm constructing the unauthorized response:
Unauthorized(views.html.invalidlogon(message)).withHeaders(
CONTENT_TYPE -> "text/plain"
)
Here's what I'd like to do in my fictional naive world:
Unauthorized(views.html.invalidlogon(message)).withHeaders(
CONTENT_TYPE -> "text/plain"
).setStatusText(message)
Thanks for the help!
Edit - Additional Info
So it turns out what I'm really looking for is the Reason Phrase.
According to the RFC they say the following:
The reason phrases listed here are only recommendations -- they MAY be replaced by local equivalents without affecting the protocol.
Of particular interest is the use of MAY with regard to the existing error codes.
However if in Play I return a custom 4XX error then the reason phrase is just Client Error following the classification of the 4XX status. It would be nice to have control over the reason phrase so that it accompanies the custom response status code.