result.setException(e);
}
private void handleDone(ClientExchange exchange, ByteArrayOutputStream out) {
Map<String, List<String>> headers = new HashMap<>();
ClientResponse response = exchange.getResponse();
for(HeaderValues header : response.getResponseHeaders()) {
List<String> values = new ArrayList<String>();
for(String val : header) {
values.add(val);
}
headers.put(header.getHeaderName().toString(), Collections.unmodifiableList(values));
}
result.setResult(new HttpResponse(response.getResponseCode(), headers, out.toByteArray()));
}
});
if(result.getIoFuture().await(10, TimeUnit.SECONDS) == IoFuture.Status.WAITING) {
throw new IOException("Timed out");
}