Search in sources :

Example 76 with HttpPut

use of org.apache.http.client.methods.HttpPut in project cdap by caskdata.

the class AppFabricTestBase method getPut.

protected static HttpPut getPut(String resource) throws Exception {
    HttpPut put = new HttpPut(getEndPoint(resource));
    put.setHeader(AUTH_HEADER);
    return put;
}
Also used : HttpPut(org.apache.http.client.methods.HttpPut)

Example 77 with HttpPut

use of org.apache.http.client.methods.HttpPut in project cdap by caskdata.

the class AppFabricTestBase method doPut.

protected static HttpResponse doPut(String resource, String body) throws Exception {
    DefaultHttpClient client = new DefaultHttpClient();
    HttpPut put = new HttpPut(getEndPoint(resource));
    if (body != null) {
        put.setEntity(new StringEntity(body));
    }
    put.setHeader(AUTH_HEADER);
    return client.execute(put);
}
Also used : StringEntity(org.apache.http.entity.StringEntity) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpPut(org.apache.http.client.methods.HttpPut)

Example 78 with HttpPut

use of org.apache.http.client.methods.HttpPut in project cdap by caskdata.

the class GatewayFastTestsSuite method doPut.

public static HttpResponse doPut(String resource) throws Exception {
    DefaultHttpClient client = new DefaultHttpClient();
    HttpPut put = new HttpPut(GatewayTestBase.getEndPoint(resource));
    put.setHeader(AUTH_HEADER);
    return client.execute(put);
}
Also used : DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpPut(org.apache.http.client.methods.HttpPut)

Example 79 with HttpPut

use of org.apache.http.client.methods.HttpPut in project cdap-ingest by caskdata.

the class RestStreamClient method create.

@Override
public void create(String stream) throws IOException {
    HttpPut putRequest = new HttpPut(restClient.resolve(String.format("/streams/%s", stream)));
    CloseableHttpResponse httpResponse = restClient.execute(putRequest);
    try {
        LOG.debug("Create Stream Response Code : {}", httpResponse.getStatusLine().getStatusCode());
        RestClient.responseCodeAnalysis(httpResponse);
    } finally {
        httpResponse.close();
    }
}
Also used : CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) HttpPut(org.apache.http.client.methods.HttpPut)

Example 80 with HttpPut

use of org.apache.http.client.methods.HttpPut in project hbase by apache.

the class Client method executePathOnly.

/**
   * Execute a transaction method given only the path. Will select at random
   * one of the members of the supplied cluster definition and iterate through
   * the list until a transaction can be successfully completed. The
   * definition of success here is a complete HTTP transaction, irrespective
   * of result code.
   * @param cluster the cluster definition
   * @param method the transaction method
   * @param headers HTTP header values to send
   * @param path the properly urlencoded path
   * @return the HTTP response code
   * @throws IOException
   */
public HttpResponse executePathOnly(Cluster cluster, HttpUriRequest method, Header[] headers, String path) throws IOException {
    IOException lastException;
    if (cluster.nodes.size() < 1) {
        throw new IOException("Cluster is empty");
    }
    int start = (int) Math.round((cluster.nodes.size() - 1) * Math.random());
    int i = start;
    do {
        cluster.lastHost = cluster.nodes.get(i);
        try {
            StringBuilder sb = new StringBuilder();
            if (sslEnabled) {
                sb.append("https://");
            } else {
                sb.append("http://");
            }
            sb.append(cluster.lastHost);
            sb.append(path);
            URI uri = new URI(sb.toString());
            if (method instanceof HttpPut) {
                HttpPut put = new HttpPut(uri);
                put.setEntity(((HttpPut) method).getEntity());
                put.setHeaders(method.getAllHeaders());
                method = put;
            } else if (method instanceof HttpGet) {
                method = new HttpGet(uri);
            } else if (method instanceof HttpHead) {
                method = new HttpHead(uri);
            } else if (method instanceof HttpDelete) {
                method = new HttpDelete(uri);
            } else if (method instanceof HttpPost) {
                HttpPost post = new HttpPost(uri);
                post.setEntity(((HttpPost) method).getEntity());
                post.setHeaders(method.getAllHeaders());
                method = post;
            }
            return executeURI(method, headers, uri.toString());
        } catch (IOException e) {
            lastException = e;
        } catch (URISyntaxException use) {
            lastException = new IOException(use);
        }
    } while (++i != start && i < cluster.nodes.size());
    throw lastException;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) HttpDelete(org.apache.http.client.methods.HttpDelete) HttpGet(org.apache.http.client.methods.HttpGet) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) HttpHead(org.apache.http.client.methods.HttpHead)

Aggregations

HttpPut (org.apache.http.client.methods.HttpPut)153 StringEntity (org.apache.http.entity.StringEntity)89 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)50 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)40 HttpResponse (org.apache.http.HttpResponse)29 Test (org.junit.Test)29 JsonNode (com.fasterxml.jackson.databind.JsonNode)27 Deployment (org.activiti.engine.test.Deployment)27 HttpPost (org.apache.http.client.methods.HttpPost)19 HttpGet (org.apache.http.client.methods.HttpGet)17 IOException (java.io.IOException)16 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)16 HttpDelete (org.apache.http.client.methods.HttpDelete)14 HttpEntity (org.apache.http.HttpEntity)13 URI (java.net.URI)12 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)12 HttpHead (org.apache.http.client.methods.HttpHead)11 Execution (org.activiti.engine.runtime.Execution)10 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)9 HttpEntityEnclosingRequestBase (org.apache.http.client.methods.HttpEntityEnclosingRequestBase)9