List of usage examples for java.net HttpURLConnection HTTP_CLIENT_TIMEOUT
int HTTP_CLIENT_TIMEOUT
To view the source code for java.net HttpURLConnection HTTP_CLIENT_TIMEOUT.
Click Source Link
From source file:org.hyperic.hq.plugin.netservices.HTTPCollector.java
private double getAvail(int code) { // There are too many options to list everything that is // successful. So, instead we are going to call out the // things that should be considered failure, everything else // is OK./*w ww . java2 s. com*/ switch (code) { case HttpURLConnection.HTTP_BAD_REQUEST: case HttpURLConnection.HTTP_FORBIDDEN: case HttpURLConnection.HTTP_NOT_FOUND: case HttpURLConnection.HTTP_BAD_METHOD: case HttpURLConnection.HTTP_CLIENT_TIMEOUT: case HttpURLConnection.HTTP_CONFLICT: case HttpURLConnection.HTTP_PRECON_FAILED: case HttpURLConnection.HTTP_ENTITY_TOO_LARGE: case HttpURLConnection.HTTP_REQ_TOO_LONG: case HttpURLConnection.HTTP_INTERNAL_ERROR: case HttpURLConnection.HTTP_NOT_IMPLEMENTED: case HttpURLConnection.HTTP_UNAVAILABLE: case HttpURLConnection.HTTP_VERSION: case HttpURLConnection.HTTP_BAD_GATEWAY: case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: return Metric.AVAIL_DOWN; default: } if (hasCredentials()) { if (code == HttpURLConnection.HTTP_UNAUTHORIZED) { return Metric.AVAIL_DOWN; } } return Metric.AVAIL_UP; }
From source file:org.opencastproject.deliver.itunesu.HTTPHelper.java
/** * Throws exception if status code is not 200. *//* ww w .ja v a 2 s . co m*/ private void checkStatusCode() { int statusCode = 0; String errorMessage = ""; try { statusCode = connection.getResponseCode(); errorMessage = connection.getResponseMessage(); } catch (IOException e) { throw new RuntimeException("Error in HTTP connection!"); } if (statusCode != HttpURLConnection.HTTP_OK) { switch (statusCode) { case HttpURLConnection.HTTP_CLIENT_TIMEOUT: errorMessage = "Request Time-Out"; break; case HttpURLConnection.HTTP_INTERNAL_ERROR: errorMessage = "Internal Server Error"; break; case HttpURLConnection.HTTP_UNAVAILABLE: errorMessage = "Service Unavailable"; break; } throw new RuntimeException(errorMessage); } }