/** * Send a GET request * @param c 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 get(Cluster c, String path, Header[] headers) throws IOException { if (httpGet != null) { httpGet.releaseConnection(); } httpGet = new HttpGet(path); HttpResponse resp = execute(c, httpGet, headers, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), resp, resp.getEntity() == null ? null : resp.getEntity().getContent()); }
/** * 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 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(); } }
/** * Send a PUT request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be * supplied * @param content the content bytes * @return a Response object with response detail * @throws IOException */ public Response put(Cluster cluster, String path, Header[] headers, byte[] content) throws IOException { HttpPut method = new HttpPut(path); try { method.setEntity(new InputStreamEntity(new ByteArrayInputStream(content), content.length)); HttpResponse resp = execute(cluster, method, headers, path); headers = resp.getAllHeaders(); content = getResponseBody(resp); return new Response(resp.getStatusLine().getStatusCode(), headers, content); } finally { method.releaseConnection(); } }
/** * Send a POST request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be * supplied * @param content the content bytes * @return a Response object with response detail * @throws IOException */ public Response post(Cluster cluster, String path, Header[] headers, byte[] content) throws IOException { HttpPost method = new HttpPost(path); try { method.setEntity(new InputStreamEntity(new ByteArrayInputStream(content), content.length)); HttpResponse resp = execute(cluster, method, headers, path); headers = resp.getAllHeaders(); content = getResponseBody(resp); return new Response(resp.getStatusLine().getStatusCode(), headers, content); } finally { method.releaseConnection(); } }
/** * 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(); } } }
/** * Send a GET request * @param c 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 get(Cluster c, String path, Header[] headers) throws IOException { if (httpGet != null) { httpGet.releaseConnection(); } httpGet = new HttpGet(path); HttpResponse resp = execute(c, httpGet, headers, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), resp, resp.getEntity() == null ? null : resp.getEntity().getContent()); }
/** * Send a GET request * @param c 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 get(Cluster c, String path, Header[] headers) throws IOException { if (httpGet != null) { httpGet.releaseConnection(); } httpGet = new HttpGet(path); HttpResponse resp = execute(c, httpGet, headers, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), resp, resp.getEntity() == null ? null : resp.getEntity().getContent()); }
/** * 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(); } }
/** * Send a PUT request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be * supplied * @param content the content bytes * @return a Response object with response detail * @throws IOException */ public Response put(Cluster cluster, String path, Header[] headers, byte[] content) throws IOException { HttpPut method = new HttpPut(path); try { method.setEntity(new InputStreamEntity(new ByteArrayInputStream(content), content.length)); HttpResponse resp = execute(cluster, method, headers, path); headers = resp.getAllHeaders(); content = getResponseBody(resp); return new Response(resp.getStatusLine().getStatusCode(), headers, content); } finally { method.releaseConnection(); } }
/** * Send a POST request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be * supplied * @param content the content bytes * @return a Response object with response detail * @throws IOException */ public Response post(Cluster cluster, String path, Header[] headers, byte[] content) throws IOException { HttpPost method = new HttpPost(path); try { method.setEntity(new InputStreamEntity(new ByteArrayInputStream(content), content.length)); HttpResponse resp = execute(cluster, method, headers, path); headers = resp.getAllHeaders(); content = getResponseBody(resp); return new Response(resp.getStatusLine().getStatusCode(), headers, content); } finally { method.releaseConnection(); } }
/** * 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(); } }
/** * 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(); } }
/** * 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(); } } }
/** * 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(); } } }
/** * Send a GET request * @param c 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 get(Cluster c, String path, Header[] headers) throws IOException { GetMethod method = new GetMethod(); try { int code = execute(c, method, headers, path); headers = method.getResponseHeaders(); byte[] body = method.getResponseBody(); return new Response(code, headers, body); } 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 { HeadMethod method = new HeadMethod(); try { int code = execute(cluster, method, null, path); headers = method.getResponseHeaders(); return new Response(code, headers, null); } finally { method.releaseConnection(); } }
/** * Send a POST request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be * supplied * @param content the content bytes * @return a Response object with response detail * @throws IOException */ public Response post(Cluster cluster, String path, Header[] headers, byte[] content) throws IOException { PostMethod method = new PostMethod(); try { method.setRequestEntity(new ByteArrayRequestEntity(content)); int code = execute(cluster, method, headers, path); headers = method.getResponseHeaders(); content = method.getResponseBody(); return new Response(code, headers, content); } finally { method.releaseConnection(); } }
/** * Send a DELETE request * @param cluster the cluster definition * @param path the path or URI * @return a Response object with response detail * @throws IOException */ public Response delete(Cluster cluster, String path) throws IOException { DeleteMethod method = new DeleteMethod(); try { int code = execute(cluster, method, null, path); Header[] headers = method.getResponseHeaders(); byte[] content = method.getResponseBody(); return new Response(code, headers, content); } finally { method.releaseConnection(); } } }