Does Java have a complete enum for HTTP response codes?
Solution 1:
I don't think there's one that's complete in the standard Java classes; HttpURLConnection
is missing quite a few codes, like HTTP 100/Continue
.
There's a complete list in the Apache HttpComponents, though:org.apache.http.HttpStatus
(replaced org.apache.commons.HttpClient.HttpStatus
from Apache Http Client, which reached end of life)
Solution 2:
The Interface 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
Solution 3:
Well, there are static constants of the exact integer values in the HttpURLConnection class
Solution 4:
If you're using Spring, the 3.x release has what your looking for: http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/http/HttpStatus.html