Java Code Examples for org.apache.http.client.methods.HttpRequestBase#abort()
The following examples show how to use
org.apache.http.client.methods.HttpRequestBase#abort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCosHttpClient.java From cos-java-sdk-v5 with MIT License | 6 votes |
private <X extends CosServiceRequest> void checkResponse(CosHttpRequest<X> request, HttpRequestBase httpRequest, HttpResponse httpResponse) { if (!isRequestSuccessful(httpResponse)) { try { throw handlerErrorMessage(request, httpRequest, httpResponse); } catch (IOException ioe) { String errorMsg = "Unable to execute HTTP request: " + ioe.getMessage(); log.error(errorMsg, ioe); CosServiceException cse = new CosServiceException(errorMsg, ioe); throw cse; } finally { httpRequest.abort(); } } }
Example 2
Source File: HttpPoolClient.java From seezoon-framework-all with Apache License 2.0 | 5 votes |
public CloseableHttpResponse execute(HttpRequestBase request) { try { return httpClient.execute(request); } catch (IOException e) { request.abort(); throw new ServiceException(e); } }
Example 3
Source File: HttpPoolClient.java From seezoon-framework-all with Apache License 2.0 | 5 votes |
public CloseableHttpResponse execute(HttpRequestBase request,HttpClientContext httpClientContext) { try { return httpClient.execute(request,httpClientContext); } catch (IOException e) { request.abort(); throw new ServiceException(e); } }
Example 4
Source File: HttpUtils.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
/** * Execute Http request and response code * @param request - HTTP Request * @param expectedCode - expected response code * @return - response in JSONObject */ public JSON query(HttpRequestBase request, int expectedCode) throws IOException { log.info("Requesting: " + request); addRequiredHeader(request); HttpParams requestParams = request.getParams(); requestParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, TIMEOUT * 1000); requestParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, TIMEOUT * 1000); synchronized (httpClient) { String response; try { HttpResponse result = httpClient.execute(request); int statusCode = result.getStatusLine().getStatusCode(); response = getResponseEntity(result); if (statusCode != expectedCode) { notifier.notifyAbout("Response with code " + statusCode + ": " + extractErrorMessage(response)); throw new IOException("API responded with wrong status code: " + statusCode); } else { log.debug("Response: " + response); } } finally { request.abort(); } if (response == null || response.isEmpty()) { return JSONNull.getInstance(); } else { return JSONSerializer.toJSON(response, new JsonConfig()); } } }
Example 5
Source File: DefaultCosHttpClient.java From cos-java-sdk-v5 with MIT License | 5 votes |
private HttpResponse executeOneRequest(HttpContext context, HttpRequestBase httpRequest) { HttpResponse httpResponse = null; try { httpResponse = httpClient.execute(httpRequest, context); } catch (IOException e) { httpRequest.abort(); throw ExceptionUtils.createClientException(e); } return httpResponse; }
Example 6
Source File: ApacheHttpClient.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Override public ExecutableHttpRequest prepareRequest(HttpExecuteRequest request) { HttpRequestBase apacheRequest = toApacheRequest(request); return new ExecutableHttpRequest() { @Override public HttpExecuteResponse call() throws IOException { return execute(apacheRequest); } @Override public void abort() { apacheRequest.abort(); } }; }
Example 7
Source File: SimpleHttpFetcher.java From ache with Apache License 2.0 | 5 votes |
private static void safeAbort(boolean needAbort, HttpRequestBase request) { if (needAbort && (request != null)) { try { request.abort(); } catch (Throwable t) { // Ignore any errors } } }
Example 8
Source File: HttpsUtils.java From RipplePower with Apache License 2.0 | 5 votes |
private static void abortConnection(final HttpRequestBase hrb) { if (hrb != null) { try { hrb.abort(); } catch (Exception e) { } } }