use of org.asynchttpclient.Response in project async-http-client by AsyncHttpClient.
the class MultipartUploadTest method sendEmptyFileInputStream.
private void sendEmptyFileInputStream(boolean disableZeroCopy) throws Exception {
File file = getClasspathFile("empty.txt");
try (AsyncHttpClient c = asyncHttpClient(config().setDisableZeroCopy(disableZeroCopy))) {
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
Request r = post("http://localhost" + ":" + port1 + "/upload").addBodyPart(new InputStreamPart("file", inputStream, file.getName(), file.length(), "text/plain", UTF_8)).build();
Response res = c.executeRequest(r).get();
assertEquals(res.getStatusCode(), 200);
}
}
use of org.asynchttpclient.Response in project async-http-client by AsyncHttpClient.
the class TimeToLiveIssue method testTTLBug.
@Test(enabled = false, description = "https://github.com/AsyncHttpClient/async-http-client/issues/1113")
public void testTTLBug() throws Throwable {
try (AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(true).setConnectionTtl(1).setPooledConnectionIdleTimeout(1))) {
for (int i = 0; i < 200000; ++i) {
Request request = new RequestBuilder().setUrl(String.format("http://localhost:%d/", port1)).build();
Future<Response> future = client.executeRequest(request);
future.get(5, TimeUnit.SECONDS);
// from sometimes winning over poll for the ownership of a connection.
if (System.currentTimeMillis() % 100 == 0) {
Thread.sleep(5);
}
}
}
}
use of org.asynchttpclient.Response in project async-http-client by AsyncHttpClient.
the class WebDavBasicTest method mkcolWebDavTest2.
@Test(groups = "standalone")
public void mkcolWebDavTest2() throws InterruptedException, IOException, ExecutionException {
try (AsyncHttpClient c = asyncHttpClient()) {
Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl() + "/folder2").build();
Response response = c.executeRequest(mkcolRequest).get();
assertEquals(response.getStatusCode(), 409);
}
}
use of org.asynchttpclient.Response in project async-http-client by AsyncHttpClient.
the class WebDavBasicTest method basicPropFindWebDavTest.
@Test(groups = "standalone")
public void basicPropFindWebDavTest() throws InterruptedException, IOException, ExecutionException {
try (AsyncHttpClient c = asyncHttpClient()) {
Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(getTargetUrl()).build();
Response response = c.executeRequest(propFindRequest).get();
assertEquals(response.getStatusCode(), 404);
}
}
use of org.asynchttpclient.Response in project async-http-client by AsyncHttpClient.
the class WebDavBasicTest method mkcolWebDavTest1.
@Test(groups = "standalone")
public void mkcolWebDavTest1() throws InterruptedException, IOException, ExecutionException {
try (AsyncHttpClient c = asyncHttpClient()) {
Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl()).build();
Response response = c.executeRequest(mkcolRequest).get();
assertEquals(response.getStatusCode(), 201);
}
}
Aggregations