The best answers to the question “Does Java have a complete enum for HTTP response codes?” in the category Dev.
I’m wondering if there is an enum type in some standard Java class library that defines symbolic constants for all of the valid HTTP response codes. It should support conversion to/from the corresponding integer values.
I’m debugging some Java code that uses
javax.ws.rs.core.Response.Status. It works, but it only defines about half of the valid HTTP response codes.
javax.servlet.http.HttpServletResponse from the servlet API has all the response codes in the form of
int constants names
SC_<description>. See http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.html
I don’t think there’s one that’s complete in the standard Java classes;
HttpURLConnection is missing quite a few codes, like
There’s a complete list in the Apache HttpComponents, though:
org.apache.commons.HttpClient.HttpStatus from Apache Http Client, which reached end of life)
If you’re using Spring, the 3.x release has what your looking for:
Well, there are static constants of the exact integer values in the HttpURLConnection class