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

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

Introduction

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

Prototype

public HttpPut() 

Source Link

Usage

From source file:org.aicer.hibiscus.http.workers.HttpWorkerPut.java

public HttpWorkerPut(HttpClient client) {
    super(client, new HttpPut());
}

From source file:com.bigdata.rockstor.console.RockStorSender.java

private static HttpRequestBase buildHttpRequest(HttpReq req)
        throws UnsupportedEncodingException, URISyntaxException {

    HttpRequestBase request = null;/*from  ww w.  j a  va 2 s. c  om*/
    if ("GET".equals(req.getMethod())) {
        request = new HttpGet();
    } else if ("PUT".equals(req.getMethod())) {
        request = new HttpPut();
        if (req.getBody() != null && req.getBody().length() > 0)
            ((HttpPut) request).setEntity(new StringEntity(req.getBody()));
    } else if ("DELETE".equals(req.getMethod())) {
        request = new HttpDelete();
    } else if ("HEAD".equals(req.getMethod())) {
        request = new HttpHead();
    } else {
        throw new NullPointerException("Unknown HTTP Method : " + req.getMethod());
    }

    request.setURI(new URI(req.getUrl()));

    if (req.getHead() != null) {
        for (Map.Entry<String, String> e : req.getHead().entrySet()) {
            if ("PUT".equals(req.getMethod()) && e.getKey().equals("Content-Length"))
                continue;
            request.setHeader(e.getKey(), e.getValue());
        }
    }

    return request;
}

From source file:com.github.yongchristophertang.engine.web.request.TestRequestBuilders.java

/**
 * Create a {@link HttpRequestBuilders} for a PUT request.
 *
 * @param urlTemplate  a URL template; the resulting URL will be encoded
 * @param urlVariables zero or more URL variables
 *//*from w  w w . ja  v  a2 s. c  o  m*/
public static HttpRequestBuilders put(String urlTemplate, Object... urlVariables) {
    return new HttpRequestBuilders(new HttpPut(), urlTemplate, "PUT Request", urlVariables);
}

From source file:HttpConnections.RestRequester.java

public RestRequester() {
    this.uri = new DiffURIBuilder();
    this.RC = new ResponseContents();
    this.httpget = new HttpGet();
    this.httpput = new HttpPut();
    this.httppost = new HttpPost();
    this.soapPost = new SoapPost();
    this.method = "";
}

From source file:net.javacrumbs.restfire.httpcomponents.HttpComponentsRequestFactory.java

public RequestBuilder put() {
    return createRequestBuilder(new HttpPut());
}

From source file:com.github.grantjforrester.bdd.rest.httpclient.HttpClientRequest.java

HttpRequestBase getRequestImpl(URI baseUri) {
    HttpRequestBase request = null;//w  ww .ja  va 2s .  c o  m

    switch (method) {
    case HEAD:
        request = new HttpHead();
        break;
    case OPTIONS:
        request = new HttpOptions();
        break;
    case GET:
        request = new HttpGet();
        break;
    case POST:
        request = new HttpPost();
        break;
    case PUT:
        request = new HttpPut();
        break;
    case DELETE:
        request = new HttpDelete();
        break;
    case PATCH:
        request = new HttpPatch();
    }

    request.setURI(baseUri.resolve(uri));
    request.setHeaders(headers.toArray(new Header[headers.size()]));
    if (content != null) {
        ((HttpEntityEnclosingRequest) request).setEntity(new ByteArrayEntity(content));
    }

    return request;
}

From source file:com.rackspacecloud.client.service_registry.clients.ConfigurationClient.java

public ConfigurationClient set(String id, String value) throws Exception {
    ConfigurationValue cv = new ConfigurationValue(null, value);
    this.performRequestWithPayload("/configuration/" + id, null, new HttpPut(), cv, false, null);
    return this;
}

From source file:com.ritesh.idea.plugin.util.HttpRequestBuilder.java

public static HttpRequestBuilder put(String url) throws URISyntaxException {
    HttpRequestBuilder builder = new HttpRequestBuilder();
    builder.urlBuilder = new URIBuilder(url);
    builder.request = new HttpPut();
    return builder;
}

From source file:com.michaeljones.httpclient.apache.ApacheMethodClient.java

@Override
public int PutQuery(String url, List<Pair<String, String>> queryParams, StringBuilder redirect) {
    try {/*from  w  w  w.  j a  v  a 2  s. co  m*/
        HttpPut httpPut = new HttpPut();
        URIBuilder fileUri = new URIBuilder(url);

        if (queryParams != null) {
            for (Pair<String, String> queryParam : queryParams) {
                fileUri.addParameter(queryParam.getFirst(), queryParam.getSecond());
            }
        }

        httpPut = new HttpPut(fileUri.build());
        CloseableHttpResponse response = clientImpl.execute(httpPut);
        try {
            Header[] hdrs = response.getHeaders("Location");
            if (redirect != null && hdrs.length > 0) {
                String redirectLocation = hdrs[0].getValue();

                redirect.append(redirectLocation);
                LOGGER.debug("Redirect to: " + redirectLocation);
            }

            return response.getStatusLine().getStatusCode();
        } finally {
            // I believe this releases the connection to the client pool, but does not
            // close the connection.
            response.close();
        }
    } catch (IOException | URISyntaxException ex) {
        throw new RuntimeException("Apache method putQuery: " + ex.getMessage());
    }
}

From source file:com.rackspacecloud.client.service_registry.clients.ServicesClient.java

public ServicesClient update(String id, List<String> tags, Map<String, String> metadata) throws Exception {
    Service service = new Service(null, null, tags, metadata);

    ClientResponse response = this.performRequestWithPayload("/services/" + id, null, new HttpPut(), service,
            true, null);// w  w  w  . j  a v  a2 s  .c o m
    return this;
}