List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete
public HttpDelete(final String uri)
From source file:org.deviceconnect.android.profile.restful.test.FailAvailabilityProfileTestCase.java
/** * ?DELETE?????.//from w w w. java2 s . co m * <pre> * ?HTTP * Method: DELETE * Path: /availability * </pre> * <pre> * ?? * result?1??????? * </pre> */ @Test public void testGetAvailabilityInvalidMethodDelete() { URIBuilder builder = TestURIBuilder.createURIBuilder(); builder.setProfile(AvailabilityProfileConstants.PROFILE_NAME); try { HttpUriRequest request = new HttpDelete(builder.toString()); JSONObject root = sendRequest(request); assertResultError(ErrorCode.NOT_SUPPORT_ACTION.getCode(), root); } catch (JSONException e) { fail("Exception in JSONObject." + e.getMessage()); } }
From source file:org.janusgraph.diskstorage.es.ElasticSearchIndexTest.java
@AfterClass public static void stopElasticsearch() throws ClientProtocolException, IOException { IOUtils.closeQuietly(httpClient.execute(host, new HttpDelete("janusgraph*"))); IOUtils.closeQuietly(httpClient);//from w ww .j a va 2s . c o m esr.stop(); }
From source file:org.flowable.admin.service.engine.FormDeploymentService.java
public void deleteDeployment(ServerConfig serverConfig, HttpServletResponse httpResponse, String appDeploymentId) { HttpDelete delete = new HttpDelete(clientUtil.getServerUrl(serverConfig, clientUtil.createUriBuilder("form-repository/deployments/" + appDeploymentId))); clientUtil.execute(delete, httpResponse, serverConfig); }
From source file:com.flipkart.phantom.http.impl.HttpProxy.java
/** * Creates a HttpRequestBase object understood by the apache http library * @param method HTTP request method//w w w .j a va2s .c o m * @param uri HTTP request URI * @param data HTTP request data * @return * @throws Exception */ private HttpRequestBase createRequest(String method, String uri, byte[] data) throws Exception { // get if ("GET".equals(method)) { HttpGet r = new HttpGet(pool.constructUrl(uri)); return r; // put } else if ("PUT".equals(method)) { HttpPut r = new HttpPut(pool.constructUrl(uri)); r.setEntity(new ByteArrayEntity(data)); return r; // post } else if ("POST".equals(method)) { HttpPost r = new HttpPost(pool.constructUrl(uri)); r.setEntity(new ByteArrayEntity(data)); return r; // delete } else if ("DELETE".equals(method)) { HttpDelete r = new HttpDelete(pool.constructUrl(uri)); return r; // invalid } else { return null; } }
From source file:org.jclouds.http.apachehc.ApacheHCUtils.java
public HttpUriRequest convertToApacheRequest(HttpRequest request) { HttpUriRequest apacheRequest;/*from ww w . ja va 2s . c o m*/ if (request.getMethod().equals(HttpMethod.HEAD)) { apacheRequest = new HttpHead(request.getEndpoint()); } else if (request.getMethod().equals(HttpMethod.GET)) { apacheRequest = new HttpGet(request.getEndpoint()); } else if (request.getMethod().equals(HttpMethod.DELETE)) { apacheRequest = new HttpDelete(request.getEndpoint()); } else if (request.getMethod().equals(HttpMethod.PUT)) { apacheRequest = new HttpPut(request.getEndpoint()); apacheRequest.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true); } else if (request.getMethod().equals(HttpMethod.POST)) { apacheRequest = new HttpPost(request.getEndpoint()); } else { final String method = request.getMethod(); if (request.getPayload() != null) apacheRequest = new HttpEntityEnclosingRequestBase() { @Override public String getMethod() { return method; } }; else apacheRequest = new HttpRequestBase() { @Override public String getMethod() { return method; } }; HttpRequestBase.class.cast(apacheRequest).setURI(request.getEndpoint()); } Payload payload = request.getPayload(); // Since we may remove headers, ensure they are added to the apache // request after this block if (apacheRequest instanceof HttpEntityEnclosingRequest) { if (payload != null) { addEntityForContent(HttpEntityEnclosingRequest.class.cast(apacheRequest), payload); } } else { apacheRequest.addHeader(HttpHeaders.CONTENT_LENGTH, "0"); } for (Map.Entry<String, String> entry : request.getHeaders().entries()) { String header = entry.getKey(); // apache automatically tries to add content length header if (!header.equals(HttpHeaders.CONTENT_LENGTH)) apacheRequest.addHeader(header, entry.getValue()); } apacheRequest.addHeader(HttpHeaders.USER_AGENT, USER_AGENT); return apacheRequest; }
From source file:no.norrs.projects.andronary.service.utils.HttpUtil.java
public static HttpResponse DEL(String uri) throws IOException { HttpClient httpClient = new DefaultHttpClient(); HttpDelete httpDelete = new HttpDelete(uri); //httpPost.addHeader("Accept", "application/json"); httpDelete.addHeader("Content-Type", "application/json; charset=utf-8"); httpDelete.addHeader("User-Agent", "Andronary/0.1"); httpDelete.addHeader("Connection", "close"); return httpClient.execute(httpDelete); }
From source file:org.apache.stratos.kubernetes.client.rest.RestClient.java
public KubernetesResponse doDelete(URI resourcePath) throws Exception { HttpDelete httpDelete = null;/*from w w w . j av a 2s . c o m*/ try { httpDelete = new HttpDelete(resourcePath); httpDelete.addHeader("Content-Type", "application/json"); return httpClient.execute(httpDelete, new KubernetesResponseHandler()); } finally { releaseConnection(httpDelete); } }
From source file:com.lovebridge.library.volley.toolbox.HttpClientStack.java
/** * Creates the appropriate subclass of HttpUriRequest for passed in request. *///from w w w. j a v a 2s .c o m @SuppressWarnings("deprecation") /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) throws AuthFailureError { switch (request.getMethod()) { case Method.DEPRECATED_GET_OR_POST: { // This is the deprecated way that needs to be handled for // backwards compatibility. // If the request's post body is null, then the assumption is // that the request is // GET. Otherwise, it is assumed that the request is a POST. byte[] postBody = request.getPostBody(); if (postBody != null) { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getPostBodyContentType()); HttpEntity entity; entity = new ByteArrayEntity(postBody); postRequest.setEntity(entity); return postRequest; } else { return new HttpGet(request.getUrl()); } } case Method.GET: return new HttpGet(request.getUrl()); case Method.DELETE: return new HttpDelete(request.getUrl()); case Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case Method.HEAD: return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl()); case Method.TRACE: return new HttpTrace(request.getUrl()); case Method.PATCH: { HttpPatch patchRequest = new HttpPatch(request.getUrl()); patchRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(patchRequest, request); return patchRequest; } default: throw new IllegalStateException("Unknown request method."); } }
From source file:org.apache.activemq.artemis.tests.integration.rest.util.RestAMQConnection.java
public void delete(String uri) throws IOException { String consumerUri = getFullLink(uri); HttpDelete delete = new HttpDelete(consumerUri); CloseableHttpResponse resp = httpClient.execute(delete); }
From source file:io.github.jonestimd.neo4j.client.http.ApacheHttpDriver.java
public HttpResponse delete(String uri) throws IOException { return new ResponseAdapter(client.execute(new HttpDelete(uri))); }