org.apache.http.client.methods.HttpDelete#releaseConnection()源码实例Demo

下面列出了org.apache.http.client.methods.HttpDelete#releaseConnection() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: docker-java-api   文件: RtNetwork.java
@Override
public void remove() throws IOException, UnexpectedResponseException {
    final UncheckedUriBuilder uri = new UncheckedUriBuilder(
        this.baseUri.toString()
    );
    final HttpDelete delete = new HttpDelete(
        uri.build()
    );
    try {
        this.client.execute(
            delete,
            new MatchStatus(delete.getURI(), HttpStatus.SC_NO_CONTENT)
        );
    } finally {
        delete.releaseConnection();
    }
}
 
源代码2 项目: docker-java-api   文件: RtVolume.java
@Override
public void remove(final boolean force)
    throws IOException, UnexpectedResponseException {
    final UncheckedUriBuilder uri = new UncheckedUriBuilder(
        this.baseUri.toString()
    );
    uri.addParameter("force", String.valueOf(force));
    final HttpDelete delete = new HttpDelete(
        uri.build()
    );
    try {
        this.client.execute(
            delete,
            new MatchStatus(delete.getURI(), HttpStatus.SC_OK)
        );
    } finally {
        delete.releaseConnection();
    }
}
 
源代码3 项目: attic-stratos   文件: DefaultRestClient.java
public HttpResponse doDelete(String resourcePath) throws RestClientException {

        HttpDelete delete = new HttpDelete(resourcePath);
        setAuthHeader(delete);

        try {
            return httpClient.execute(delete);

        } catch (IOException e) {
            String errorMsg = "Error while executing DELETE statement";
            log.error(errorMsg, e);
            throw new RestClientException(errorMsg, e);
        } finally {
            delete.releaseConnection();
        }
    }
 
源代码4 项目: cxf   文件: JAXRSClientServerBookTest.java
@Test
public void testDeleteBook() throws Exception {
    String endpointAddress =
        "http://localhost:" + PORT + "/bookstore/books/123";

    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpDelete delete = new HttpDelete(endpointAddress);

    try {
        CloseableHttpResponse response = client.execute(delete);
        assertEquals(200, response.getStatusLine().getStatusCode());
    } finally {
        // Release current connection to the connection pool once you are done
        delete.releaseConnection();
    }
}
 
源代码5 项目: cxf   文件: JAXRSClientServerBookTest.java
@Test
public void testDeleteBookByQuery() throws Exception {
    String endpointAddress =
        "http://localhost:" + PORT + "/bookstore/books/id?value=123";

    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpDelete delete = new HttpDelete(endpointAddress);

    try {
        CloseableHttpResponse response = client.execute(delete);
        assertEquals(200, response.getStatusLine().getStatusCode());
    } finally {
        // Release current connection to the connection pool once you are done
        delete.releaseConnection();
    }
}
 
源代码6 项目: cloudstack   文件: BrocadeVcsApi.java
protected void executeDeleteObject(String uri) throws BrocadeVcsApiException {
    if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
        throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
    }

    final HttpDelete dm = (HttpDelete)createMethod("delete", uri);
    dm.setHeader("Accept", "application/vnd.configuration.resource+xml");

    final HttpResponse response = executeMethod(dm);

    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {

        String errorMessage;
        try {
            errorMessage = responseToErrorMessage(response);
        } catch (final IOException e) {
            s_logger.error("Failed to delete object : " + e.getMessage());
            throw new BrocadeVcsApiException("Failed to delete object : " + e.getMessage());
        }

        dm.releaseConnection();
        s_logger.error("Failed to delete object : " + errorMessage);
        throw new BrocadeVcsApiException("Failed to delete object : " + errorMessage);
    }
    dm.releaseConnection();
}
 
源代码7 项目: redis-manager   文件: HttpClientUtil.java
public static String delete(String url) throws IOException {
    HttpDelete httpDelete = deleteForm(url);
    HttpResponse response;
    String result = null;
    try {
        response = httpclient.execute(httpDelete);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            result = EntityUtils.toString(entity);
        }
    } finally {
        httpDelete.releaseConnection();
    }
    return result;
}
 
源代码8 项目: hbase   文件: Client.java
/**
 * Send a DELETE request
 * @param cluster the cluster definition
 * @param path the path or URI
 * @return a Response object with response detail
 * @throws IOException for error
 */
public Response delete(Cluster cluster, String path) throws IOException {
  HttpDelete method = new HttpDelete(path);
  try {
    HttpResponse resp = execute(cluster, method, null, path);
    Header[] headers = resp.getAllHeaders();
    byte[] content = getResponseBody(resp);
    return new Response(resp.getStatusLine().getStatusCode(), headers, content);
  } finally {
    method.releaseConnection();
  }
}
 
源代码9 项目: hbase   文件: Client.java
/**
 * Send a DELETE request
 * @param cluster the cluster definition
 * @param path the path or URI
 * @return a Response object with response detail
 * @throws IOException for error
 */
public Response delete(Cluster cluster, String path, Header extraHdr) throws IOException {
  HttpDelete method = new HttpDelete(path);
  try {
    Header[] headers = { extraHdr };
    HttpResponse resp = execute(cluster, method, headers, path);
    headers = resp.getAllHeaders();
    byte[] content = getResponseBody(resp);
    return new Response(resp.getStatusLine().getStatusCode(), headers, content);
  } finally {
    method.releaseConnection();
  }
}