private String checkResponse(final HttpMethodBase m, final String errorMessageBase) throws BigSwitchBcfApiException, IllegalArgumentException{ String customErrorMsg = null; if (m.getStatusCode() == HttpStatus.SC_OK) { String hash = ""; if (m.getResponseHeader(HASH_MATCH) != null) { if (m.getStatusCode() == HttpStatus.SC_CONFLICT) { if(m instanceof GetMethod) { return HASH_CONFLICT; if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) { isMaster = false; set_hash(HASH_IGNORE); return HASH_IGNORE; if (m.getStatusCode() == HttpStatus.SC_NOT_FOUND) { if (m instanceof DeleteMethod){ return ""; if (m.getStatusCode() == HttpStatus.SC_BAD_REQUEST) { customErrorMsg = " Invalid data in BCF request"; throw new IllegalArgumentException(customErrorMsg);
protected void executeMethod(final HttpMethodBase method) throws BigSwitchBcfApiException { try { _client.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { method.releaseConnection(); } } catch (HttpException e) { S_LOGGER.error("HttpException caught while trying to connect to the BigSwitch Controller", e); method.releaseConnection(); throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e); } catch (IOException e) { S_LOGGER.error("IOException caught while trying to connect to the BigSwitch Controller", e); method.releaseConnection(); throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e); } }
public int getStatusCode() { return method == null ? 0 : method.getStatusCode(); }
/** * Return the response status code * * @return the response status code */ public int getStatusCode() { return method.getStatusCode(); }
public int getStatusCode() { return method == null ? 0 : method.getStatusCode(); }
@Override public int getStatusCode() { return method.getStatusCode(); }
public String toString() { StringBuilder sb = new StringBuilder(getClass().getSimpleName()); sb.append("[Method=").append(method.getName()); sb.append("\n\tHTTP version=").append(method.getEffectiveVersion()); sb.append("\n\tstatus code=").append(method.getStatusCode()); sb.append("\n\tpath=").append(method.getPath()); sb.append("\n\tquery string=").append(method.getQueryString()); sb.append("\n\tresponse charset=").append(getResponseCharset()); Header[] responseHeaders = method.getResponseHeaders(); sb.append("\n\tresponse headers="); for (Header header : responseHeaders) { sb.append(header.toExternalForm()); } sb.append("]"); return sb.toString(); } }
private File getResponseBodyAsFile(HttpMethodBase method) throws IOException { //we'd like to avoid creation of tmp files if something went wrong //it will reduce disc IO operations during handling invalid requests //for example all non-authenticated responses won't cause creation (and then deletion) temp files on disk if (method.getStatusCode() == HttpStatus.SC_FORBIDDEN || method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { throw new FailedOperationException(method.getStatusCode(), CharStreams.toString( new InputStreamReader(new BoundedInputStream(method.getResponseBodyAsStream(), 5000)))); } File responseTempFile = File.createTempFile("confluence.extra.webdav-responsebody-", null); InputStream in = null; OutputStream out = null; try { in = method.getResponseBodyAsStream(); if (null != in) { in = new BufferedInputStream(in); out = new BufferedOutputStream(new FileOutputStream(responseTempFile)); IOUtils.copy(in, out); } return responseTempFile; } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(in); } }
private String executeRequest(HttpMethodBase method) { String json = null; try { httpClient.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_OK) { json = getResponseBodyAsString(method); } else if (method.getStatusCode() != HttpStatus.SC_NOT_FOUND) { throw new ConnectionException("HTTP error: " + method.getStatusCode() + ", msg: " + method.getStatusText() + ", query: " + method); } } catch (HttpException e) { throw new ConnectionException("Query: " + method, e); } catch (IOException e) { throw new ConnectionException("Query: " + method, e); } finally { if (method != null) { method.releaseConnection(); } } return json; }
int statusCode = method.getStatusCode();
private boolean checkStatusCode(URL url, HttpMethodBase method) throws IOException { int status = method.getStatusCode(); if (status == HttpStatus.SC_OK) { return true; } // IVY-1328: some servers return a 204 on a HEAD request if ("HEAD".equals(method.getName()) && (status == 204)) { return true; } Message.debug("HTTP response status: " + status + " url=" + url); if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) { Message.warn("Your proxy requires authentication."); } else if (String.valueOf(status).startsWith("4")) { Message.verbose("CLIENT ERROR: " + method.getStatusText() + " url=" + url); } else if (String.valueOf(status).startsWith("5")) { Message.error("SERVER ERROR: " + method.getStatusText() + " url=" + url); } return false; }
if (method.getStatusCode() == 200) { state = State.AUTHORIZED; } else { throw new ProponoException("ERROR: authorization returned code: " + method.getStatusCode());
try { method = executeRequest(wmsBackendUrl, wmsParams, backendTimeout, httpRequestMode); responseCode = method.getStatusCode(); responseLength = (int) method.getResponseContentLength();
return; int statusCode = method.getStatusCode(); HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode); log.trace("Handling response - " + statusCode);