} else { log.error("recieved response status code:" + get.getStatusCode() + " text : " + get.getStatusText());
lastHttpStatus = client.executeMethod(httpMethod); if(lastHttpStatus != HttpStatus.SC_OK) { LOGGER.warn("PING failed at '"+url+"': ("+lastHttpStatus+") " + httpMethod.getStatusText()); return false; } else {
public static boolean httpPing(String url, String username, String pw) { GetMethod httpMethod = null; HttpClient client = new HttpClient(); HttpConnectionManager connectionManager = client.getHttpConnectionManager(); try { setAuth(client, url, username, pw); httpMethod = new GetMethod(url); connectionManager.getParams().setConnectionTimeout(2000); int status = client.executeMethod(httpMethod); if (status != HttpStatus.SC_OK) { LOGGER.warn("PING failed at '" + url + "': (" + status + ") " + httpMethod.getStatusText()); return false; } else { return true; } } catch (ConnectException e) { return false; } catch (IOException e) { LOGGER.error(e.getLocalizedMessage(),e); return false; } finally { if (httpMethod != null) httpMethod.releaseConnection(); connectionManager.closeIdleConnections(0); } }
@Override public void onSuccess(GetMethod getMethod) { if (getMethod.getStatusCode() >= 400) { if (getMethod.getStatusCode() == 401) { LOG.info("Ignoring HTTP response status code 401 (" + getMethod.getStatusText() + ") for image URL " + completeUrlAsString); } else { handleError("HTTP server responded with: " + getMethod.getStatusCode() + " " + getMethod.getStatusText()); } } else { final Header contentTypeHeader = getMethod.getResponseHeader("Content-Type"); if (contentTypeHeader == null) { handleError("HTTP response did not contain Content-Type header."); } else { final String contentType = contentTypeHeader.getValue(); if (!contentType.startsWith("image/")) { handleError("Content-Type HTTP response header \"" + contentType + "\" does not start with \"image/\"."); } else { // TODO: check if the response body is a valid image } } } }
default: throw new RuntimeException("Unhandled response status at '" + url + "': (" + status + ") " + httpMethod.getStatusText());
return false; default: throw new RuntimeException("Unhandled response status at '"+url+"': ("+lastHttpStatus+") " + httpMethod.getStatusText());
int status = get.getStatusCode(); if (status != 200) { String text = get.getStatusText(); log.error("Error access SRU interface, status code '{}' returned with message: {}", status, text); return null;
private String fetchData(String uri) { try { GetMethod method = new GetMethod(uri); client.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_OK) { return method.getResponseBodyAsString(); } else { String msg = method.getStatusCode() + " " + method.getStatusText(); l.debug("Exception executing " + method.getName() + " on " + method.getPath() + ": " + msg); throw new HttpMethodException(msg); } } catch (HttpException e) { l.debug("Error invoking Facebook REST API.", e); throw new HttpMethodException("Error invoking Facebook REST API.", e); } catch (IOException e) { l.debug("Error invoking GoodData REST API.", e); throw new HttpMethodException("Error invoking Facebook REST API.", e); } }
throw new IOException( "HTTP " + method.getStatusCode() + " (" + HttpStatus.getStatusText(method.getStatusCode()) + ")\n" + method.getStatusText());
throw new IOException( "HTTP " + method.getStatusCode() + " (" + HttpStatus.getStatusText(method.getStatusCode()) + ")\n" + method.getStatusText());
throw new IOException("Failed to crawl repository: " + getMethod.getStatusText());
TransmitterException ex = new TransmitterException(method.getStatusText()); throw ex;
+ get.getStatusCode() + " Status message from the get request:" + get.getStatusText() + " Reason phrase: "+get.getStatusLine().getReasonPhrase());
if (method.getStatusCode() != 200) { throw new IOException( "Failed to fetch " + uri + ": " + method.getStatusCode() + " " + method.getStatusText() );
final Css result = new Css(); if (getMethod.getStatusCode() >= 400) { LOG.error("Could not get CSS from " + cssUrl + " -- HTTP server responded with: " + getMethod.getStatusCode() + " " + getMethod.getStatusText()); } else { InputStream in = null;