Search in sources :

Example 1 with ExecutionContext

use of com.amazonaws.http.ExecutionContext in project sandbox by irof.

the class AmazonHttpClientTest method sendRequest.

private void sendRequest(Supplier<AmazonHttpClient> client) {
    Request<?> request = new DefaultRequest<>("test-service");
    request.setEndpoint(server.getUri());
    InputStream in = new ByteArrayInputStream("hoge".getBytes(StandardCharsets.UTF_8));
    request.setContent(in);
    client.get().execute(request, new HttpResponseHandler<AmazonWebServiceResponse<Object>>() {

        @Override
        public AmazonWebServiceResponse<Object> handle(HttpResponse response) throws Exception {
            return new AmazonWebServiceResponse<>();
        }

        @Override
        public boolean needsConnectionLeftOpen() {
            return false;
        }
    }, new HttpResponseHandler<AmazonServiceException>() {

        @Override
        public AmazonServiceException handle(HttpResponse response) throws Exception {
            return null;
        }

        @Override
        public boolean needsConnectionLeftOpen() {
            return false;
        }
    }, new ExecutionContext());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpResponse(com.amazonaws.http.HttpResponse) ExecutionContext(com.amazonaws.http.ExecutionContext) ByteArrayInputStream(java.io.ByteArrayInputStream)

Aggregations

ExecutionContext (com.amazonaws.http.ExecutionContext)1 HttpResponse (com.amazonaws.http.HttpResponse)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1