/** * Send a HEAD request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include in the request * @return a Response object with response detail * @throws IOException */ public Response head(Cluster cluster, String path, Header[] headers) throws IOException { HttpHead method = new HttpHead(path); try { HttpResponse resp = execute(cluster, method, null, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), null); } finally { method.releaseConnection(); } }
/** * Tests for the index existence with specified name. * * @param name the name of the index to test. * @return true if index with given name exists and false otherwise. * @throws IOException communication exception. */ public boolean indexExists(String name) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpHead head = new HttpHead(String.format("http://%s:%d/%s", host, port, name)); try { CloseableHttpResponse response = client.execute(head); return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK; } finally { head.releaseConnection(); } }
private static boolean hasInteractionData(String repoName, String globiFilename) throws IOException { HttpHead request = new HttpHead(getBaseUrlMaster(repoName) + "/" + globiFilename); try { HttpResponse execute = HttpUtil.getHttpClient().execute(request); return execute.getStatusLine().getStatusCode() == 200; } finally { request.releaseConnection(); } }
private boolean exists(SessionInfo sInfo, String uri) { HttpHead request = new HttpHead(uri); try { int statusCode = executeRequest(sInfo, request).getStatusLine().getStatusCode(); return (statusCode == DavServletResponse.SC_OK); } catch (IOException e) { log.error("Unexpected error while testing existence of item.", e); return false; } catch (RepositoryException e) { log.error(e.getMessage()); return false; } finally { request.releaseConnection(); } }
private boolean exists(SessionInfo sInfo, String uri) { HttpHead request = new HttpHead(uri); try { int statusCode = executeRequest(sInfo, request).getStatusLine().getStatusCode(); return (statusCode == DavServletResponse.SC_OK); } catch (IOException e) { log.error("Unexpected error while testing existence of item.", e); return false; } catch (RepositoryException e) { log.error(e.getMessage()); return false; } finally { request.releaseConnection(); } }
/** * Send a HEAD request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include in the request * @return a Response object with response detail * @throws IOException */ public Response head(Cluster cluster, String path, Header[] headers) throws IOException { HttpHead method = new HttpHead(path); try { HttpResponse resp = execute(cluster, method, null, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), null); } finally { method.releaseConnection(); } }
/** * Send a HEAD request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include in the request * @return a Response object with response detail * @throws IOException */ public Response head(Cluster cluster, String path, Header[] headers) throws IOException { HttpHead method = new HttpHead(path); try { HttpResponse resp = execute(cluster, method, null, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), null); } finally { method.releaseConnection(); } }
public Map<String, String> loadHeaders(String uri, String[] headerNames) throws IOException, RepositoryException { HttpHead request = new HttpHead(uri); try { HttpResponse response = client.execute(request, context); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == DavServletResponse.SC_OK) { Map<String, String> headers = new HashMap<String, String>(); for (String name : headerNames) { Header hdr = response.getFirstHeader(name); if (hdr != null) { headers.put(name, hdr.getValue()); } } return headers; } else { throw ExceptionConverter.generate(new DavException(statusCode, ("Unable to load headers at " + uri + " - Status line = " + response.getStatusLine().toString()))); } } finally { request.releaseConnection(); } }
public Map<String, String> loadHeaders(String uri, String[] headerNames) throws IOException, RepositoryException { HttpHead request = new HttpHead(uri); try { HttpResponse response = client.execute(request, context); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == DavServletResponse.SC_OK) { Map<String, String> headers = new HashMap<String, String>(); for (String name : headerNames) { Header hdr = response.getFirstHeader(name); if (hdr != null) { headers.put(name, hdr.getValue()); } } return headers; } else { throw ExceptionConverter.generate(new DavException(statusCode, ("Unable to load headers at " + uri + " - Status line = " + response.getStatusLine().toString()))); } } finally { request.releaseConnection(); } }
} finally { if (null != method) { method.releaseConnection();
headMethod.releaseConnection();
httpHead.releaseConnection(); httpClient = null;