private static String readResponse(URLConnection connection, String encoding) throws IOException {
        if ( !isValidContentType(connection) )
            throw new IOException("Invalid content type for " + connection.getURL());

        BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream(), encoding) );

        String line, lines = "";
        while (( line = reader.readLine() ) != null)
            lines += line + "\n";

        reader.close();
        return lines;
    }