protected CloseableHttpResponse delete(String path) throws IOException { HttpDelete delete = new HttpDelete(String.format("%s/%s", baseUrl, path)); return execute(delete); }
HttpDelete(IgnitedHttp ignitedHttp, String url, HashMap<String, String> defaultHeaders) { super(ignitedHttp); request = new org.apache.http.client.methods.HttpDelete(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); } }
public HttpResponse doDelete(String uri, String username, String password) { HttpDelete httpDelete = new HttpDelete(context + uri); return doRequest(httpDelete, username, password); }
private HttpUriRequest newDelete(String url) { return addDefaultHeaders(new HttpDelete(url)); }
public static HttpUriRequest newDelete(String url) { return addDefaultHeaders(new HttpDelete(url)); }
/** * Tell the broker that the given message has been successfully processed by a worker (HTTP DELETE). */ public void deleteRequest(AnalystClusterRequest clusterRequest) { String url = BROKER_BASE_URL + String.format("/tasks/%s", clusterRequest.taskId); HttpDelete httpDelete = new HttpDelete(url); try { HttpResponse response = httpClient.execute(httpDelete); // Signal the http client library that we're done with this response object, allowing connection reuse. EntityUtils.consumeQuietly(response.getEntity()); if (response.getStatusLine().getStatusCode() == 200) { LOG.info("Successfully deleted task {}.", clusterRequest.taskId); } else { LOG.info("Failed to delete task {} ({}).", clusterRequest.taskId, response.getStatusLine()); } } catch (Exception e) { LOG.warn("Failed to delete task {}", clusterRequest.taskId, e); } }
private int httpDelete(String endpoint) throws IOException { requestTimedout.setIsSatisfied(false); Thread timer = new Thread(new Timer(execTimeout, requestTimedout)); timer.start(); int responseCode = 200; HttpDelete request = new HttpDelete(endpoint); for (int i = 0; i < headers.length; i = i + 2) { request.setHeader(headers[i], headers[i + 1]); } CloseableHttpResponse response = client.execute(request); responseCode = response.getStatusLine().getStatusCode(); response.close(); client.close(); return responseCode; }
private HttpRequestBase createBaseRequest(final URL url, final HttpMethod method) { if (method == HttpMethod.GET) { return new HttpGet(url.toString()); } if (method == HttpMethod.POST) { return new HttpPost(url.toString()); } if (method == HttpMethod.PUT) { return new HttpPut(url.toString()); } if (method == HttpMethod.DELETE) { return new HttpDelete(url.toString()); } if (method == HttpMethod.HEAD) { return new HttpHead(url.toString()); } if (method == HttpMethod.OPTIONS) { return new HttpOptions(url.toString()); } if (method == HttpMethod.TRACE) { return new HttpTrace(url.toString()); } if (method == HttpMethod.PATCH) { return new HttpPatch(url.toString()); } throw new MocoException("unknown HTTP method"); }
/** * 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(); } } }
private void httpDelete(String url, AjaxStatus status) throws IOException{ AQUtility.debug("get", url); url = patchUrl(url); HttpDelete del = new HttpDelete(url); httpDo(del, url, status); }
private HttpDelete createDelete(final String path) { final URI url = getUri(path); final HttpDelete delete = new HttpDelete(url); delete.setConfig(getRequestConfig()); return delete; }
method = new HttpHead(uri); } else if (method instanceof HttpDelete) { method = new HttpDelete(uri); } else if (method instanceof HttpPost) { HttpPost post = new HttpPost(uri);
req = new HttpDelete(url); break;
private HttpRequestBase createApacheRequest(Request<?> request, String uri, String encodedParams) throws FakeIOException { switch (request.getHttpMethod()) { case HEAD: return new HttpHead(uri); case GET: return wrapEntity(request, new HttpGetWithBody(uri), encodedParams); case DELETE: return new HttpDelete(uri); case OPTIONS: return new HttpOptions(uri); case PATCH: return wrapEntity(request, new HttpPatch(uri), encodedParams); case POST: return wrapEntity(request, new HttpPost(uri), encodedParams); case PUT: return wrapEntity(request, new HttpPut(uri), encodedParams); default: throw new SdkClientException("Unknown HTTP method name: " + request.getHttpMethod()); } }
@Test public void parseParams_returnsNullForUnsupportedOperations() throws Exception { HttpDelete httpDelete = new HttpDelete("http://example.com/deleteme"); assertThat(ParamsParser.parseParams(httpDelete)).isEmpty(); } }
public HttpResponse executeDeleteRequest(final String request, Header... header) throws Exception { return executeRequest(new HttpDelete(getHttpServerUri() + "/" + request), header); }
@Test public void testNonPostRequest() throws Exception { final HttpUriRequest[] reqs = { new HttpGet(newUri("http", "/hello")), new HttpDelete(newUri("http", "/hello")) }; try (CloseableHttpClient hc = HttpClients.createMinimal()) { for (HttpUriRequest r: reqs) { try (CloseableHttpResponse res = hc.execute(r)) { assertThat(res.getStatusLine().toString()).isEqualTo( "HTTP/1.1 405 Method Not Allowed"); assertThat(EntityUtils.toString(res.getEntity())) .isNotEqualTo("Hello, world!"); } } } }
return new HttpGet(request.getUrl()); case Method.DELETE: return new HttpDelete(request.getUrl()); case Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl());
return new HttpGet(request.getUrl()); case Method.DELETE: return new HttpDelete(request.getUrl()); case Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl());