This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getCompressedResource(String urlString) throws IOException { | |
// NOTE: Android's HTTPURLConnection automatically adds the "accept-encoding: gzip" header to requests and deflates responses. | |
// This code sample demonstrates how you would implement this feature if it wasn't handled for you automatically. | |
URL url = new URL(urlString); | |
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); | |
conn.setRequestProperty("accept-encoding", "gzip"); | |
conn.setRequestMethod("GET"); | |
InputStream is = new BufferedInputStream(conn.getInputStream()); | |
// Note: If the library did not automatically deflate the response, we would need to use a GZipInputStream on the response. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |