in cloudwatch-lambda/src/main/java/com/amazonwebservices/blogs/containers/sigv4/util/HttpUtils.java [44:70]
public static String executeHttpRequest(HttpURLConnection connection) {
try {
// Get Response
InputStream is;
try {
is = connection.getInputStream();
} catch (IOException e) {
is = connection.getErrorStream();
}
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
return response.toString();
} catch (Exception e) {
throw new RuntimeException("Request failed. " + e.getMessage(), e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
}