I still can't understand how to read the content of an AWS response while I'm doing calls to my Elastic Search Service signing the requests. It seems like the stream is consumed somewhere. The only way I can, for example, print the response content as a string, is inside a ResponseHandler. I'm using Amazon AWS Java SDK 1.11.170.
AmazonHttpClient client = new AmazonHttpClient(new ClientConfiguration());
Response<Void> response = client
.requestExecutionBuilder()
.request(request)
//.errorResponseHandler(errorHandler)
.executionContext(context)
//.execute(responseHandler)
.execute()
;
System.out.println("response = " + convertStreamToString(response.getHttpResponse().getContent()));
This code breaks down and says:
java.io.IOException: Attempted read from closed stream.
Is there a way to keep the stream open after the request execution and outside the response handler?