Example usage for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod

List of usage examples for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod.

Prototype

public DeleteMethod() 

Source Link

Usage

From source file:org.eclipse.swordfish.plugins.resolver.proxy.impl.HttpCilentProxy.java

private HttpMethodBase getMethod(Method method) {
    HttpMethodBase result = null;// w w w  .j  a v a  2s.  c om

    if (method.equals(Method.GET)) {
        result = new GetMethod();
    } else if (method.equals(Method.POST)) {
        result = new PostMethod();
    } else if (method.equals(Method.DELETE)) {
        result = new DeleteMethod();
    } else if (method.equals(Method.PUT)) {
        result = new PutMethod();
    }
    return result;
}

From source file:org.httpobjects.proxy.Proxy.java

@Override
public Response delete(Request req) {
    return proxyRequest(req, new DeleteMethod());
}

From source file:org.nuxeo.ecm.core.opencmis.impl.client.protocol.http.HttpURLConnection.java

protected HttpMethod newMethod(String name) {
    if ("GET".equals(name)) {
        return new GetMethod();
    }/* ww w .  ja  v a 2s.c o  m*/
    if ("POST".equals(name)) {
        return new PostMethod();
    }
    if ("DELETE".equals(name)) {
        return new DeleteMethod();
    }
    if ("PUT".equals(name)) {
        return new PutMethod();
    }
    throw new UnsupportedOperationException("Unsupported method " + name);
}

From source file:org.tuckey.web.filters.urlrewrite.RequestProxy.java

private static HttpMethod setupProxyRequest(final HttpServletRequest hsRequest, final URL targetUrl)
        throws IOException {
    final String methodName = hsRequest.getMethod();
    final HttpMethod method;
    if ("POST".equalsIgnoreCase(methodName)) {
        PostMethod postMethod = new PostMethod();
        InputStreamRequestEntity inputStreamRequestEntity = new InputStreamRequestEntity(
                hsRequest.getInputStream());
        postMethod.setRequestEntity(inputStreamRequestEntity);
        method = postMethod;/*from  w  ww.  j a v  a  2 s  . c om*/
    } else if ("GET".equalsIgnoreCase(methodName)) {
        method = new GetMethod();
    } else if ("PUT".equalsIgnoreCase(methodName)) {
        PutMethod putMethod = new PutMethod();
        InputStreamRequestEntity inputStreamRequestEntity = new InputStreamRequestEntity(
                hsRequest.getInputStream());
        putMethod.setRequestEntity(inputStreamRequestEntity);
        method = putMethod;
    } else if ("DELETE".equalsIgnoreCase(methodName)) {
        method = new DeleteMethod();
    } else {
        log.warn("Unsupported HTTP method requested: " + hsRequest.getMethod());
        return null;
    }

    method.setFollowRedirects(false);
    method.setPath(targetUrl.getPath());
    method.setQueryString(targetUrl.getQuery());

    Enumeration e = hsRequest.getHeaderNames();
    if (e != null) {
        while (e.hasMoreElements()) {
            String headerName = (String) e.nextElement();
            if ("host".equalsIgnoreCase(headerName)) {
                //the host value is set by the http client
                continue;
            } else if ("content-length".equalsIgnoreCase(headerName)) {
                //the content-length is managed by the http client
                continue;
            } else if ("accept-encoding".equalsIgnoreCase(headerName)) {
                //the accepted encoding should only be those accepted by the http client.
                //The response stream should (afaik) be deflated. If our http client does not support
                //gzip then the response can not be unzipped and is delivered wrong.
                continue;
            } else if (headerName.toLowerCase().startsWith("cookie")) {
                //fixme : don't set any cookies in the proxied request, this needs a cleaner solution
                continue;
            }

            Enumeration values = hsRequest.getHeaders(headerName);
            while (values.hasMoreElements()) {
                String headerValue = (String) values.nextElement();
                log.info("setting proxy request parameter:" + headerName + ", value: " + headerValue);
                method.addRequestHeader(headerName, headerValue);
            }
        }
    }

    if (log.isInfoEnabled())
        log.info("proxy query string " + method.getQueryString());
    return method;
}

From source file:org.xwiki.test.webdav.AbstractWebDAVTest.java

/**
 * Tests the DELETE method on the given url.
 * //from   w  ww. j av  a  2s . co m
 * @param url the target url.
 * @param expect the return status expected.
 * @return the {@link HttpMethod} which contains the response.
 */
protected HttpMethod delete(String url, int expect) {
    DeleteMethod deleteMethod = new DeleteMethod();
    deleteMethod.setDoAuthentication(true);
    deleteMethod.setPath(url);
    testMethod(deleteMethod, expect);
    return deleteMethod;
}

From source file:org.xwiki.webdav.test.AbstractWebDAVTest.java

/**
 * Tests the DELETE method on the given url.
 * /*from w  ww  . ja v  a  2s.  c  o  m*/
 * @param url the target url.
 * @param expect the return status expected.
 * @return the {@link HttpMethod} which contains the response.
 */
protected HttpMethod delete(String url, int expect) throws Exception {
    DeleteMethod deleteMethod = new DeleteMethod();
    deleteMethod.setDoAuthentication(true);
    deleteMethod.setPath(url);
    testMethod(deleteMethod, expect);
    return deleteMethod;
}