use of org.apache.http.client.methods.HttpPut in project crate by crate.
the class BlobHttpClient method put.
public CloseableHttpResponse put(String table, String body) throws IOException {
CloseableHttpClient httpClient = HttpClients.createDefault();
String digest = Hex.encodeHexString(Blobs.digest(body));
String url = Blobs.url(address, table + "/" + digest);
HttpPut httpPut = new HttpPut(url);
httpPut.setEntity(new StringEntity(body));
return httpClient.execute(httpPut);
}
use of org.apache.http.client.methods.HttpPut in project crate by crate.
the class BlobIntegrationTest method testIndexOnNonBlobTable.
@Test
public void testIndexOnNonBlobTable() throws IOException {
// this test works only if ES API is enabled
HttpPut httpPut = new HttpPut(String.format(Locale.ENGLISH, "http://%s:%s/test_no_blobs/default/1", address.getHostName(), address.getPort()));
String blobData = String.format(Locale.ENGLISH, "{\"content\": \"%s\"}", StringUtils.repeat("a", 1024 * 64));
httpPut.setEntity(new StringEntity(blobData, ContentType.APPLICATION_OCTET_STREAM));
CloseableHttpResponse res = httpClient.execute(httpPut);
assertThat(res.getStatusLine().getStatusCode(), is(201));
assertThat(res.getStatusLine().getReasonPhrase(), is("Created"));
assertThat(EntityUtils.toString(res.getEntity()), is("{\"_index\":\"test_no_blobs\",\"_type\":\"default\"," + "\"_id\":\"1\",\"_version\":1,\"_shards\":{\"total\":1,\"successful\":1,\"failed\":0},\"created\":true}"));
}
use of org.apache.http.client.methods.HttpPut in project crate by crate.
the class SQLHttpIntegrationTest method upload.
protected String upload(String table, String content) throws IOException {
String digest = blobDigest(content);
String url = Blobs.url(address, table, digest);
HttpPut httpPut = new HttpPut(url);
httpPut.setEntity(new StringEntity(content));
CloseableHttpResponse response = httpClient.execute(httpPut);
assertThat(response.getStatusLine().getStatusCode(), is(201));
response.close();
return url;
}
use of org.apache.http.client.methods.HttpPut in project gocd by gocd.
the class RemoteConsoleAppender method append.
public void append(String content) throws IOException {
HttpPut putMethod = new HttpPut(consoleUri);
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Appending console to URL -> " + consoleUri);
}
putMethod.setEntity(new StringEntity(content, Charset.defaultCharset()));
HttpService.setSizeHeader(putMethod, content.getBytes().length);
CloseableHttpResponse response = httpService.execute(putMethod);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Got " + response.getStatusLine().getStatusCode());
}
} finally {
putMethod.releaseConnection();
}
}
use of org.apache.http.client.methods.HttpPut in project iosched by google.
the class HttpClientStackTest method testCreatePutRequest.
public void testCreatePutRequest() throws Exception {
TestRequest.Put request = new TestRequest.Put();
assertEquals(request.getMethod(), Method.PUT);
HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
assertTrue(httpRequest instanceof HttpPut);
}
Aggregations