I'm trying to use a Java library to validate the universe of possible HTTP Responses, rather than writing my own logic to check each response code individually.
I've found a static class Response.Status
in javax.ws.rs which seems to perfectly fit this purpose. Its documentation states:
Commonly used status codes defined by HTTP, see HTTP/1.1 documentation for the complete list.
If you visit the link to the HTTP/1.1 docs, referenced by the javax documentation, clearly you see the 302
response status code as being valid.
However, the following call returns null
, meaning that "the matching Status or null is no matching Status is defined" - which is obviously incorrect:
Response.Status.fromStatusCode(302);
And sure enough, 302
/FOUND
is not in the enumeration defined in this class.
Does anyone have any idea why this is? Is it an oversight in the javax.ws.rs
code - or was this done intentionally?
The enum value Response.Status.FOUND
(302) was added in 2.0 (along with several other response codes missing from earlier versions).