in legacy/java/TopSites.java [102:124]
public static String makeRequest(String requestUrl, String authorization, String amzDate) throws IOException {
URL url = new URL(requestUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Accept", "application/xml");
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestProperty("X-Amz-Date", amzDate);
conn.setRequestProperty("Authorization", authorization);
InputStream in = (conn.getResponseCode() / 100 == 2 ? conn.getInputStream() : conn.getErrorStream());
// Read the response
StringBuffer sb = new StringBuffer();
int c;
int lastChar = 0;
while ((c = in.read()) != -1) {
if (c == '<' && (lastChar == '>'))
sb.append('\n');
sb.append((char) c);
lastChar = c;
}
in.close();
return sb.toString();
}