Search in sources :

Example 1 with HelloRequest

use of com.tvd12.ezyhttp.client.test.request.HelloRequest in project ezyfox-examples by tvd12.

the class ApiGetUserTest method main.

public static void main(String[] args) throws Exception {
    HttpClientProxy httpClient = HttpClientProxy.builder().build();
    httpClient.start();
    RequestEntity entity = RequestEntity.builder().build();
    Request helloRequest = new GetRequest().setURL(API_URL + "tvd12").setEntity(entity).setResponseType(String.class).setResponseType(StatusCodes.NOT_FOUND, String.class);
    String response = httpClient.call(helloRequest, 10000);
    System.out.println("get user response: " + response);
}
Also used : GetRequest(com.tvd12.ezyhttp.client.request.GetRequest) GetRequest(com.tvd12.ezyhttp.client.request.GetRequest) Request(com.tvd12.ezyhttp.client.request.Request) HttpClientProxy(com.tvd12.ezyhttp.client.HttpClientProxy) RequestEntity(com.tvd12.ezyhttp.client.request.RequestEntity)

Example 2 with HelloRequest

use of com.tvd12.ezyhttp.client.test.request.HelloRequest in project ezyhttp by youngmonkeys.

the class HttpClientProxyTest method postTest.

protected static void postTest(HttpClientProxy client) throws Exception {
    HelloRequest body = new HelloRequest();
    body.setWho("dzung");
    RequestEntity entity = RequestEntity.body(body);
    PostRequest request = new PostRequest().setURL("http://localhost:8081/").setEntity(entity).setResponseType(String.class).setReadTimeout(HttpClient.NO_TIMEOUT).setConnectTimeout(HttpClient.NO_TIMEOUT);
    String response = client.call(request, 1000);
    System.out.println(response);
}
Also used : HelloRequest(com.tvd12.ezyhttp.client.test.request.HelloRequest)

Example 3 with HelloRequest

use of com.tvd12.ezyhttp.client.test.request.HelloRequest in project ezyhttp by youngmonkeys.

the class HttpClientTest method postTest.

protected static void postTest() throws Exception {
    HttpClient client = HttpClient.builder().build();
    HelloRequest body = new HelloRequest();
    body.setWho("dzung");
    RequestEntity entity = RequestEntity.body(body);
    PostRequest request = new PostRequest().setURL("http://localhost:8081/").setEntity(entity).setResponseType(String.class).setReadTimeout(HttpClient.NO_TIMEOUT).setConnectTimeout(HttpClient.NO_TIMEOUT);
    String response = client.call(request);
    System.out.println(response);
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) HelloRequest(com.tvd12.ezyhttp.client.test.request.HelloRequest) RequestEntity(com.tvd12.ezyhttp.client.request.RequestEntity)

Aggregations

RequestEntity (com.tvd12.ezyhttp.client.request.RequestEntity)2 HelloRequest (com.tvd12.ezyhttp.client.test.request.HelloRequest)2 HttpClient (com.tvd12.ezyhttp.client.HttpClient)1 HttpClientProxy (com.tvd12.ezyhttp.client.HttpClientProxy)1 GetRequest (com.tvd12.ezyhttp.client.request.GetRequest)1 PostRequest (com.tvd12.ezyhttp.client.request.PostRequest)1 Request (com.tvd12.ezyhttp.client.request.Request)1