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.FailServiceDiscoveryProfileTestCase.java
/** * DELETE???.//from www .j ava2 s . c o m * * <pre> * ?HTTP * Method: DELETE * Path: /servicediscovery * </pre> * * <pre> * ?? * result?1??????? * </pre> */ @Test public void testGetServices003() { URIBuilder builder = TestURIBuilder.createURIBuilder(); builder.setProfile(ServiceDiscoveryProfileConstants.PROFILE_NAME); builder.addParameter(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN, getAccessToken()); try { HttpUriRequest request = new HttpDelete(builder.toString()); JSONObject root = sendRequest(request); assertResultError(ErrorCode.NOT_SUPPORT_ATTRIBUTE.getCode(), root); } catch (JSONException e) { fail("Exception in JSONObject." + e.getMessage()); } }
From source file:cn.com.xxutils.volley.toolbox.HttpClientStack.java
/** * Creates the appropriate subclass of HttpUriRequest for passed in request. *//*from w ww . j a v a2 s . co m*/ @SuppressWarnings("deprecation") /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) throws AuthFailureError { switch (request.getMethod()) { case Request.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 Request.Method.GET: return new HttpGet(request.getUrl()); case Request.Method.DELETE: return new HttpDelete(request.getUrl()); case Request.Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Request.Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case Request.Method.HEAD: return new HttpHead(request.getUrl()); case Request.Method.OPTIONS: return new HttpOptions(request.getUrl()); case Request.Method.TRACE: return new HttpTrace(request.getUrl()); case Request.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:com.connectsdk.service.command.ServiceCommand.java
public HttpRequestBase getRequest() { if (target == null) { throw new IllegalStateException("ServiceCommand has no target url"); }/* w w w.j a v a 2s . com*/ if (this.httpMethod.equalsIgnoreCase(TYPE_GET)) { return new HttpGet(target); } else if (this.httpMethod.equalsIgnoreCase(TYPE_POST)) { return new HttpPost(target); } else if (this.httpMethod.equalsIgnoreCase(TYPE_DEL)) { return new HttpDelete(target); } else if (this.httpMethod.equalsIgnoreCase(TYPE_PUT)) { return new HttpPut(target); } else { return null; } }
From source file:com.activiti.service.activiti.AppService.java
public void deleteAppDeployment(ServerConfig serverConfig, HttpServletResponse httpResponse, String appDeploymentId) { HttpDelete delete = new HttpDelete(clientUtil.getServerUrl(serverConfig, clientUtil.createUriBuilder(MessageFormat.format(APP_URL, appDeploymentId)))); clientUtil.execute(delete, httpResponse, serverConfig); }
From source file:com.griddynamics.jagger.invoker.http.HttpInvoker.java
private HttpRequestBase createMethod(HttpQuery query, URI uri) throws UnsupportedEncodingException { HttpRequestBase method;/*from ww w .j a v a2 s. com*/ switch (query.getMethod()) { case POST: method = new HttpPost(uri); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> methodParam : query.getMethodParams().entrySet()) { nameValuePairs.add(new BasicNameValuePair(methodParam.getKey(), methodParam.getValue())); } ((HttpPost) method).setEntity(new UrlEncodedFormEntity(nameValuePairs)); break; case PUT: method = new HttpPut(uri); break; case GET: method = new HttpGet(uri); break; case DELETE: method = new HttpDelete(uri); break; case TRACE: method = new HttpTrace(uri); break; case HEAD: method = new HttpHead(uri); break; case OPTIONS: method = new HttpOptions(uri); break; default: throw new UnsupportedOperationException( "Invoker does not support \"" + query.getMethod() + "\" HTTP request."); } return method; }
From source file:de.lgblaumeiser.ptm.cli.rest.RestUtils.java
/** * Delete an entity via a rest call//from www. j av a2 s . co m * * @param apiName * The api name for the deletion */ public void delete(String apiName) { try { final String requestString = baseUrl + apiName; final HttpDelete request = new HttpDelete(requestString); HttpResponse response = clientConnector.execute(request); checkState(response.getStatusLine().getStatusCode() == 200, "Cannot access server properly, Status " + response.getStatusLine() + ", URI: " + requestString); } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:com.derson.pumelo.network.volley.toolbox.HttpClientStack.java
/** * Creates the appropriate subclass of HttpUriRequest for passed in request. *///from ww w. j a v a 2s . c om @SuppressWarnings("deprecation") /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) throws AuthFailureError { switch (request.getMethod()) { case Request.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 Request.Method.GET: return new HttpGet(request.getUrl()); case Request.Method.DELETE: return new HttpDelete(request.getUrl()); case Request.Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Request.Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case Request.Method.HEAD: return new HttpHead(request.getUrl()); case Request.Method.OPTIONS: return new HttpOptions(request.getUrl()); case Request.Method.TRACE: return new HttpTrace(request.getUrl()); case Request.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:com.vanillasource.gerec.httpclient.AsyncApacheHttpClient.java
@Override public CompletableFuture<HttpResponse> doDelete(URI uri, HttpRequest.HttpRequestChange change) { return execute(new HttpDelete(uri), change); }
From source file:com.selene.volley.stack.HttpClientStack.java
/** * Creates the appropriate subclass of HttpUriRequest for passed in request. *//*from w ww. j ava 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(HTTP.CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HTTP.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(HTTP.CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(patchRequest, request); return patchRequest; } default: throw new IllegalStateException("Unknown request method."); } }
From source file:com.microsoft.cognitive.speakerrecognition.SpeakerRestClientHelper.java
/** * Creates an HTTP request// w ww . j av a 2 s . co m * * @param resourceURL HTTP resource address * @param requestType HTTP request type * @return HTTP request */ HttpUriRequest createHttpRequest(String resourceURL, RequestType requestType) { HttpUriRequest request; switch (requestType) { case GET: request = new HttpGet(resourceURL); break; case POST: request = new HttpPost(resourceURL); break; case DELETE: request = new HttpDelete(resourceURL); break; default: return null; } request.addHeader(JSON_HEADER_ACCEPT, JSON_HEADER_VALUE_ACCEPT); request.addHeader(OCP_SUBSCRIPTION_KEY_HEADER, subscriptionKey); return request; }