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;
}
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);
}
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);
}
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();
}
}
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;
}
Aggregations