List of usage examples for org.apache.commons.httpclient.methods DeleteMethod setFollowRedirects
@Override public void setFollowRedirects(boolean followRedirects)
From source file:davmail.http.DavGatewayHttpClientFacade.java
/** * Execute a delete method on the given path with httpClient. * * @param httpClient Http client instance * @param path Path to be deleted//from w w w . j av a2 s. c o m * @return http status * @throws IOException on error */ public static int executeDeleteMethod(HttpClient httpClient, String path) throws IOException { DeleteMethod deleteMethod = new DeleteMethod(path); deleteMethod.setFollowRedirects(false); int status = executeHttpMethod(httpClient, deleteMethod); // do not throw error if already deleted if (status != HttpStatus.SC_OK && status != HttpStatus.SC_NOT_FOUND) { throw DavGatewayHttpClientFacade.buildHttpException(deleteMethod); } return status; }
From source file:com.sun.faban.driver.transport.hc3.ApacheHC3Transport.java
/** * Makes a DELETE request to the URL. Reads data back and returns the data * read. Note that this method only works with text data as it does the * byte-to-char conversion. This method will return null for responses * with binary MIME types. The addTextType(String) method is used to * register additional MIME types as text types. Use getContentSize() to * obtain the bytes of binary data read. * * @param url The URL to read from/* ww w .j a v a 2s .c o m*/ * @param headers The request headers, or null * @return The StringBuilder buffer containing the resulting document * @throws java.io.IOException */ public StringBuilder deleteURL(String url, Map<String, String> headers) throws IOException { DeleteMethod method = new DeleteMethod(url); method.setFollowRedirects(followRedirects); setHeaders(method, headers); try { responseCode = hc.executeMethod(method); buildResponseHeaders(method); return fetchResponse(method); } finally { method.releaseConnection(); } }
From source file:org.apache.webdav.lib.WebdavResource.java
/** * Execute the DELETE method for the given path. * * @param path the server relative path of the resource to delete * @return true if the method is succeeded. * @exception HttpException/* www.java 2s .c om*/ * @exception IOException */ public boolean deleteMethod(String path) throws HttpException, IOException { setClient(); DeleteMethod method = new DeleteMethod(URIUtil.encodePath(path)); method.setDebug(debug); method.setFollowRedirects(this.followRedirects); generateIfHeader(method); generateTransactionHeader(method); generateAdditionalHeaders(method); int statusCode = client.executeMethod(method); setStatusCode(statusCode); return (statusCode >= 200 && statusCode < 300) ? true : false; }
From source file:org.bibsonomy.rest.client.worker.impl.DeleteWorker.java
@Override protected DeleteMethod getMethod(final String url, String requestBody) { final DeleteMethod delete = new DeleteMethod(url); delete.setFollowRedirects(true); return delete; }