List of usage examples for org.apache.http.client.methods HttpDelete METHOD_NAME
String METHOD_NAME
To view the source code for org.apache.http.client.methods HttpDelete METHOD_NAME.
Click Source Link
From source file:com.uploader.Vimeo.java
public VimeoResponse endUploadVideo(String completeUri) throws IOException { return apiRequest(completeUri, HttpDelete.METHOD_NAME, null, null); }
From source file:org.apache.edgent.test.connectors.http.HttpTest.java
@Test public void testDelete() throws Exception { DirectProvider ep = new DirectProvider(); Topology topology = ep.newTopology(); String url = "http://httpbin.org/delete"; TStream<String> stream = topology.strings(url); TStream<String> rc = HttpStreams.<String, String>requests(stream, HttpClients::noAuthentication, t -> HttpDelete.METHOD_NAME, t -> t, HttpResponders.inputOn200()); Tester tester = topology.getTester(); Condition<List<String>> endCondition = tester.streamContents(rc, url); tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS); assertTrue(endCondition.valid());/*from w ww . j a v a 2s . c o m*/ }
From source file:org.apache.zeppelin.notebook.repo.zeppelinhub.rest.HttpProxyClient.java
private HttpAsyncClientBuilder setRedirects(HttpAsyncClientBuilder clientBuilder) { clientBuilder.setRedirectStrategy(new DefaultRedirectStrategy() { /** Redirectable methods. */ private String[] REDIRECT_METHODS = new String[] { HttpGet.METHOD_NAME, HttpPost.METHOD_NAME, HttpPut.METHOD_NAME, HttpDelete.METHOD_NAME, HttpHead.METHOD_NAME }; @Override//from w w w.j av a2s .c o m protected boolean isRedirectable(String method) { for (String m : REDIRECT_METHODS) { if (m.equalsIgnoreCase(method)) { return true; } } return false; } }); return clientBuilder; }
From source file:code.google.restclient.core.Hitter.java
/** * Method to make POST or PUT request by sending http entity (as body) *//*ww w .ja v a2 s .c o m*/ public void hit(String url, String methodName, HttpHandler handler, Map<String, String> requestHeaders) throws Exception { if (DEBUG_ENABLED) LOG.debug("hit() - method => " + methodName + ", url => " + url); if (HttpGet.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> GET " + url); hit(url, new HttpGet(url), handler, requestHeaders); } else if (HttpHead.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> HEAD " + url); hit(url, new HttpHead(url), handler, requestHeaders); } else if (HttpDelete.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> DELETE " + url); hit(url, new HttpDelete(url), handler, requestHeaders); } else if (HttpOptions.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> OPTIONS " + url); hit(url, new HttpOptions(url), handler, requestHeaders); } else if (HttpTrace.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> TRACE " + url); hit(url, new HttpTrace(url), handler, requestHeaders); } else if (HttpPost.METHOD_NAME.equals(methodName)) { // POST if (DEBUG_ENABLED) LOG.debug("hit() - ===> POST " + url); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(handler.getReqBodyEntity()); hit(url, httpPost, handler, requestHeaders); } else if (HttpPut.METHOD_NAME.equals(methodName)) { // PUT if (DEBUG_ENABLED) LOG.debug("hit() - ===> PUT " + url); HttpPut httpPut = new HttpPut(url); httpPut.setEntity(handler.getReqBodyEntity()); hit(url, httpPut, handler, requestHeaders); } else { throw new IllegalArgumentException("hit(): Unsupported method => " + methodName); } }
From source file:org.elasticsearch.client.RequestConverters.java
static Request delete(DeleteRequest deleteRequest) { String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id()); Request request = new Request(HttpDelete.METHOD_NAME, endpoint); Params parameters = new Params(request); parameters.withRouting(deleteRequest.routing()); parameters.withTimeout(deleteRequest.timeout()); parameters.withVersion(deleteRequest.version()); parameters.withVersionType(deleteRequest.versionType()); parameters.withRefreshPolicy(deleteRequest.getRefreshPolicy()); parameters.withWaitForActiveShards(deleteRequest.waitForActiveShards()); return request; }
From source file:com.evolveum.midpoint.report.impl.ReportNodeUtils.java
private static HttpRequestBase buildHttpRequest(String typeOfRequest) { HttpRequestBase httpRequest;/*from w w w . java2s .com*/ if (HttpDelete.METHOD_NAME.equals(typeOfRequest)) { httpRequest = new HttpDelete(); } else { httpRequest = new HttpGet(); } return httpRequest; }
From source file:com.uploader.Vimeo.java
public VimeoResponse unlikeVideo(String videoId) throws IOException { return apiRequest(new StringBuffer("/me/likes/").append(videoId).toString(), HttpDelete.METHOD_NAME, null, null);// ww w . j a v a2s . c o m }
From source file:org.elasticsearch.client.RequestConverters.java
static Request deleteIndex(DeleteIndexRequest deleteIndexRequest) { String endpoint = endpoint(deleteIndexRequest.indices()); Request request = new Request(HttpDelete.METHOD_NAME, endpoint); Params parameters = new Params(request); parameters.withTimeout(deleteIndexRequest.timeout()); parameters.withMasterTimeout(deleteIndexRequest.masterNodeTimeout()); parameters.withIndicesOptions(deleteIndexRequest.indicesOptions()); return request; }
From source file:com.microsoft.windowsazure.mobileservices.http.MobileServiceHttpClient.java
/** * Makes a request over HTTP/*from w w w. j a v a2s. com*/ * * @param path The path of the request URI * @param content The byte array to send as the request body * @param httpMethod The HTTP Method used to invoke the API * @param requestHeaders The extra headers to send in the request * @param parameters The query string parameters sent in the request * @param features The features used in the request */ public ListenableFuture<ServiceFilterResponse> request(String path, byte[] content, String httpMethod, List<Pair<String, String>> requestHeaders, List<Pair<String, String>> parameters, EnumSet<MobileServiceFeatures> features) { final SettableFuture<ServiceFilterResponse> future = SettableFuture.create(); if (path == null || path.trim().equals("")) { future.setException(new IllegalArgumentException("request path cannot be null")); return future; } if (httpMethod == null || httpMethod.trim().equals("")) { future.setException(new IllegalArgumentException("httpMethod cannot be null")); return future; } Uri.Builder uriBuilder = Uri.parse(mClient.getAppUrl().toString()).buildUpon(); uriBuilder.path(path); if (parameters != null && parameters.size() > 0) { for (Pair<String, String> parameter : parameters) { uriBuilder.appendQueryParameter(parameter.first, parameter.second); } } ServiceFilterRequestImpl request; String url = uriBuilder.build().toString(); if (httpMethod.equalsIgnoreCase(HttpGet.METHOD_NAME)) { request = new ServiceFilterRequestImpl(new HttpGet(url), mClient.getAndroidHttpClientFactory()); } else if (httpMethod.equalsIgnoreCase(HttpPost.METHOD_NAME)) { request = new ServiceFilterRequestImpl(new HttpPost(url), mClient.getAndroidHttpClientFactory()); } else if (httpMethod.equalsIgnoreCase(HttpPut.METHOD_NAME)) { request = new ServiceFilterRequestImpl(new HttpPut(url), mClient.getAndroidHttpClientFactory()); } else if (httpMethod.equalsIgnoreCase(HttpPatch.METHOD_NAME)) { request = new ServiceFilterRequestImpl(new HttpPatch(url), mClient.getAndroidHttpClientFactory()); } else if (httpMethod.equalsIgnoreCase(HttpDelete.METHOD_NAME)) { request = new ServiceFilterRequestImpl(new HttpDelete(url), mClient.getAndroidHttpClientFactory()); } else { future.setException(new IllegalArgumentException("httpMethod not supported")); return future; } String featuresHeader = MobileServiceFeatures.featuresToString(features); if (featuresHeader != null) { if (requestHeaders == null) { requestHeaders = new ArrayList<Pair<String, String>>(); } boolean containsFeatures = false; for (Pair<String, String> header : requestHeaders) { if (header.first.equals(X_ZUMO_FEATURES)) { containsFeatures = true; break; } } if (!containsFeatures) { // Clone header list to prevent changing user's list requestHeaders = new ArrayList<Pair<String, String>>(requestHeaders); requestHeaders.add(new Pair<String, String>(X_ZUMO_FEATURES, featuresHeader)); } } if (requestHeaders != null && requestHeaders.size() > 0) { for (Pair<String, String> header : requestHeaders) { request.addHeader(header.first, header.second); } } if (content != null) { try { request.setContent(content); } catch (Exception e) { future.setException(e); return future; } } MobileServiceConnection conn = mClient.createConnection(); new RequestAsyncTask(request, conn) { @Override protected void onPostExecute(ServiceFilterResponse response) { if (mTaskException != null) { future.setException(mTaskException); } else { future.set(response); } } }.executeTask(); return future; }
From source file:com.uploader.Vimeo.java
public VimeoResponse removeEmbedPreset(String videoEndPoint, String presetId) throws IOException { return apiRequest(new StringBuffer(videoEndPoint).append("/presets/").append(presetId).toString(), HttpDelete.METHOD_NAME, null, null); }