List of usage examples for org.apache.commons.httpclient HttpMethodBase isRequestSent
@Override public boolean isRequestSent()
From source file:com.cloud.network.bigswitch.BigSwitchVnsApi.java
private String responseToErrorMessage(HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) { // The error message is the response content // Safety margin of 1024 characters, anything longer is probably useless // and will clutter the logs try {/*from ww w . ja va 2s. c om*/ return method.getResponseBodyAsString(1024); } catch (IOException e) { s_logger.debug("Error while loading response body", e); } } // The default return method.getStatusText(); }
From source file:com.cloud.utils.rest.RESTServiceConnector.java
private String responseToErrorMessage(final HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; if (TEXT_HTML_CONTENT_TYPE.equals(method.getResponseHeader(CONTENT_TYPE).getValue())) { // The error message is the response content // Safety margin of 1024 characters, anything longer is probably useless // and will clutter the logs try {//from w w w .j a va2s . co m return method.getResponseBodyAsString(BODY_RESP_MAX_LEN); } catch (final IOException e) { s_logger.debug("Error while loading response body", e); } } // The default return method.getStatusText(); }
From source file:com.cloud.network.bigswitch.BigSwitchBcfApi.java
private String responseToErrorMessage(final HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) { // The error message is the response content // Safety margin of 2048 characters, anything longer is probably useless // and will clutter the logs try {//w w w.j a v a2s . co m return method.getResponseBodyAsString(2048); } catch (IOException e) { S_LOGGER.debug("Error while loading response body", e); } } // The default return method.getStatusText(); }
From source file:com.cloud.network.nicira.NiciraNvpApi.java
private String responseToErrorMessage(HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; if ("text/html".equals(method.getResponseHeader("Content-Type").getValue())) { // The error message is the response content // Safety margin of 1024 characters, anything longer is probably useless // and will clutter the logs try {/*from w w w. j a v a 2 s . co m*/ return method.getResponseBodyAsString(1024); } catch (IOException e) { s_logger.debug("Error while loading response body", e); } } // The default return method.getStatusText(); }
From source file:org.apache.cloudstack.network.opendaylight.api.resources.Action.java
private String responseToErrorMessage(final HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; final Header contentTypeHeader = method.getResponseHeader(CONTENT_TYPE); if (contentTypeHeader != null && TEXT_HTML_CONTENT_TYPE.equals(contentTypeHeader.getValue())) { // The error message is the response content // Safety margin of 1024 characters, anything longer is probably // useless and will clutter the logs try {// w w w. j av a 2s .c om return method.getResponseBodyAsString(BODY_RESP_MAX_LEN); } catch (IOException e) { s_logger.debug("Error while loading response body", e); } } // The default return method.getStatusText(); }