Example usage for org.apache.http.client.methods HttpDelete HttpDelete

List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpDelete HttpDelete.

Prototype

public HttpDelete(final String uri) 

Source Link

Usage

From source file:tools.devnull.boteco.client.rest.impl.DefaultRestClient.java

@Override
public RestConfiguration delete(URI uri) {
    return execute(new HttpDelete(uri));
}

From source file:com.aliyun.oss.common.comm.HttpRequestFactory.java

public HttpRequestBase createHttpRequest(ServiceClient.Request request, ExecutionContext context) {
    String uri = request.getUri();
    HttpRequestBase httpRequest;//from   www .  j  av a 2 s  . com
    HttpMethod method = request.getMethod();
    if (method == HttpMethod.POST) {
        HttpPost postMethod = new HttpPost(uri);

        if (request.getContent() != null) {
            postMethod.setEntity(new RepeatableInputStreamEntity(request));
        }

        httpRequest = postMethod;
    } else if (method == HttpMethod.PUT) {
        HttpPut putMethod = new HttpPut(uri);

        if (request.getContent() != null) {
            if (request.isUseChunkEncoding()) {
                putMethod.setEntity(buildChunkedInputStreamEntity(request));
            } else {
                putMethod.setEntity(new RepeatableInputStreamEntity(request));
            }
        }

        httpRequest = putMethod;
    } else if (method == HttpMethod.GET) {
        httpRequest = new HttpGet(uri);
    } else if (method == HttpMethod.DELETE) {
        httpRequest = new HttpDelete(uri);
    } else if (method == HttpMethod.HEAD) {
        httpRequest = new HttpHead(uri);
    } else if (method == HttpMethod.OPTIONS) {
        httpRequest = new HttpOptions(uri);
    } else {
        throw new ClientException("Unknown HTTP method name: " + method.toString());
    }

    configureRequestHeaders(request, context, httpRequest);

    return httpRequest;
}

From source file:org.janusgraph.diskstorage.es.ElasticSearchIndexTest.java

@BeforeClass
public static void startElasticsearch() throws Exception {
    esr = new ElasticsearchRunner();
    esr.start();//w w  w  .j  a  va  2 s.  c  o m
    httpClient = HttpClients.createDefault();
    objectMapper = new ObjectMapper();
    host = new HttpHost(InetAddress.getByName(esr.getHostname()), ElasticsearchRunner.PORT);
    if (esr.getEsMajorVersion().value > 2) {
        IOUtils.closeQuietly(httpClient.execute(host, new HttpDelete("_ingest/pipeline/pipeline_1")));
        final HttpPut newPipeline = new HttpPut("_ingest/pipeline/pipeline_1");
        newPipeline.setHeader("Content-Type", "application/json");
        newPipeline.setEntity(
                new StringEntity("{\"description\":\"Test pipeline\",\"processors\":[{\"set\":{\"field\":\""
                        + STRING + "\",\"value\":\"hello\"}}]}", Charset.forName("UTF-8")));
        IOUtils.closeQuietly(httpClient.execute(host, newPipeline));
    }
}

From source file:tools.devnull.boteco.client.rest.impl.DefaultRestClient.java

@Override
public RestConfiguration delete(String url) {
    return execute(new HttpDelete(url));
}

From source file:org.keycloak.client.registration.cli.util.HttpUtil.java

public static void doDelete(String url, String authorization) {
    try {/*www .  ja  va2  s  . c o m*/
        HttpDelete request = new HttpDelete(url);
        doRequest(authorization, request);
    } catch (IOException e) {
        throw new RuntimeException("Failed to send request - " + e.getMessage(), e);
    }
}

From source file:com.github.technosf.posterer.transports.commons.CommonsResponseModelTaskImpl.java

/**
 * @param uri/*from ww  w  .j a  v a2  s  .co m*/
 * @param method
 * @return
 */
private static HttpUriRequest createRequest(URI uri, String method) {
    switch (method) {
    case "GET":
        return new HttpGet(uri);
    case "HEAD":
        return new HttpHead(uri);
    case "POST":
        return new HttpPost(uri);
    case "PUT":
        return new HttpPut(uri);
    case "DELETE":
        return new HttpDelete(uri);
    case "TRACE":
        return new HttpTrace(uri);
    case "OPTIONS":
        return new HttpOptions(uri);
    case "PATCH":
        return new HttpPatch(uri);
    }

    return null;
}

From source file:com.prestomation.android.sospy.monitor.AppEngineClient.java

public HttpResponse makeRequest(String httpMethod, String urlPath, List<NameValuePair> params)
        throws Exception {
    HttpUriRequest request;//  w  w w .jav a  2s. co m
    URI uri = new URI(BASE_URL + urlPath);
    Log.w(TAG, uri.toString());

    if (httpMethod == "POST") {
        request = new HttpPost(uri);
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
        ((HttpPost) request).setEntity(entity);
    } else if (httpMethod == "DELETE") {
        request = new HttpDelete(uri);
    } else {
        //This should never happen
        return null;
    }

    HttpResponse res = makeRequestNoRetry(request, params);
    return res;
}

From source file:com.zlk.bigdemo.android.volley.toolbox.HttpClientStack.java

/**
 * Creates the appropriate subclass of HttpUriRequest for passed in request.
 *//*from   w w  w. j  ava 2 s. com*/
@SuppressWarnings("deprecation")
/* protected */ static HttpUriRequest createHttpRequest(Request<?> request,
        Map<String, String> additionalHeaders) throws AuthFailureError {
    switch (request.getMethod()) {
    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;
    }
    default:
        throw new IllegalStateException("Unknown request method.");
    }
}

From source file:ai.eve.volley.stack.HttpClientStack.java

/**
 * Creates the appropriate subclass of HttpUriRequest for passed in request.
 *//* w w  w.j a  va2 s.  c  om*/
private static HttpUriRequest createHttpRequest(Request<?> request) throws AuthFailureError {
    switch (request.getMethod()) {
    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:net.modelbased.proasense.storage.registry.RestRequest.java

public static String deleteSensor(URI uri, Sensor sensor) {
    URI target = null;//from  www.j a  v  a2  s . com
    try {
        target = new URI(uri.toString() + SENSOR_PATH + "/" + sensor.getName());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    HttpClient client = new DefaultHttpClient();
    HttpDelete request = new HttpDelete(target);
    request.setHeader("Content-type", "application/json");
    String response = null;
    try {
        response = resolveResponse(client.execute(request));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return response;
}