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

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

Introduction

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

Prototype

@Override
public void addRequestHeader(Header header) 

Source Link

Document

Adds the specified request header, NOT overwriting any previous value.

Usage

From source file:com.bigdata.rdf.sail.remoting.GraphRepositoryClient.java

/**
 * @see {@link GraphRepository#delete(String)}
 *///  w  w w. ja  v  a 2  s .co m
public void delete(String rdfXml) throws Exception {

    // DELETE
    DeleteMethod del = new DeleteMethod(servletURL);
    try {

        // add the range header
        if (rdfXml != null) {
            String triples = "triples[" + trim(rdfXml) + "]";
            Header range = new Header(GraphRepositoryServlet.HTTP_RANGE, triples);
            del.addRequestHeader(range);
        }

        // Execute the method.
        int sc = getHttpClient().executeMethod(del);
        if (sc != HttpStatus.SC_OK) {
            throw new IOException("HTTP-DELETE failed: " + del.getStatusLine());
        }

    } finally {
        // Release the connection.
        del.releaseConnection();
    }

}

From source file:com.bigdata.rdf.sail.remoting.GraphRepositoryClient.java

/**
 * @see {@link GraphRepository#delete(String, QueryLanguage)}
 *//*from www . j a v a 2  s  . c om*/
public void delete(String query, QueryLanguage ql) throws Exception {

    if (query == null || ql == null) {
        return;

    }
    // DELETE
    DeleteMethod del = new DeleteMethod(servletURL);

    try {

        // add the header for the query
        if (query != null) {
            query = ql.toString().toLowerCase() + "[" + trim(query) + "]";
            String rangeHeader = "query[" + query + "]";
            Header range = new Header(GraphRepositoryServlet.HTTP_RANGE, rangeHeader);
            del.addRequestHeader(range);
        }

        // Execute the method.
        int sc = getHttpClient().executeMethod(del);
        if (sc != HttpStatus.SC_OK) {
            throw new IOException("HTTP-DELETE failed: " + del.getStatusLine());
        }

    } finally {
        // Release the connection.
        del.releaseConnection();
    }

}

From source file:com.xmlcalabash.library.HttpRequest.java

private DeleteMethod doDelete() {
    DeleteMethod method = new DeleteMethod(requestURI.toASCIIString());

    // Provide custom retry handler is necessary
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(3, false));

    for (Header header : headers) {
        method.addRequestHeader(header);
    }/*from  www . j  av a 2s .c o m*/

    return method;
}