Search in sources :

Example 21 with RequestBuilder

use of org.asynchttpclient.RequestBuilder 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);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Example 22 with RequestBuilder

use of org.asynchttpclient.RequestBuilder 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);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Example 23 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class HttpsProxyTest method testRequestProxy.

@Test(groups = "standalone")
public void testRequestProxy() throws Exception {
    try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config().setFollowRedirect(true).setUseInsecureTrustManager(true))) {
        RequestBuilder rb = get(getTargetUrl2()).setProxyServer(proxyServer("localhost", port1));
        Response r = asyncHttpClient.executeRequest(rb.build()).get();
        assertEquals(r.getStatusCode(), 200);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Example 24 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class HttpsProxyTest method testPooledConnectionsWithProxy.

@Test(groups = "standalone")
public void testPooledConnectionsWithProxy() throws Exception {
    try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config().setFollowRedirect(true).setUseInsecureTrustManager(true).setKeepAlive(true))) {
        RequestBuilder rb = get(getTargetUrl2()).setProxyServer(proxyServer("localhost", port1));
        Response r1 = asyncHttpClient.executeRequest(rb.build()).get();
        assertEquals(r1.getStatusCode(), 200);
        Response r2 = asyncHttpClient.executeRequest(rb.build()).get();
        assertEquals(r2.getStatusCode(), 200);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Example 25 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class SimpleAsyncHttpClient method options.

public Future<Response> options(BodyConsumer bodyConsumer) throws IOException {
    RequestBuilder r = rebuildRequest(requestBuilder.build());
    r.setMethod("OPTIONS");
    return execute(r, bodyConsumer, null);
}
Also used : RequestBuilder(org.asynchttpclient.RequestBuilder)

Aggregations

RequestBuilder (org.asynchttpclient.RequestBuilder)44 Request (org.asynchttpclient.Request)18 AsyncHttpClient (org.asynchttpclient.AsyncHttpClient)17 Test (org.testng.annotations.Test)17 Response (org.asynchttpclient.Response)14 AbstractBasicTest (org.asynchttpclient.AbstractBasicTest)9 Realm (org.asynchttpclient.Realm)4 SpnegoEngineException (org.asynchttpclient.spnego.SpnegoEngineException)4 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)3 Uri (org.asynchttpclient.uri.Uri)3 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)2 HttpRequest (io.netty.handler.codec.http.HttpRequest)2 UUID (java.util.UUID)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Consumer (java.util.function.Consumer)2 Slf4j (lombok.extern.slf4j.Slf4j)2 lombok.val (lombok.val)2 Request (okhttp3.Request)2 Response (okhttp3.Response)2 REQUEST (org.asynchttpclient.extras.retrofit.AsyncHttpClientCallTest.REQUEST)2