code: public static String parseHttpResponse(HttpURLConnection conn, boolean includeHeaders, boolean ignoreBody) throws IOException {
          StringBuilder buff = new StringBuilder();
          if (includeHeaders) {
              buff.append(conn.getResponseCode()).append(' ').append(conn.getResponseMessage()).append('\n');
              int idx = (conn.getHeaderFieldKey(0) == null) ? 1 : 0;
              while (true) {
                  String key = conn.getHeaderFieldKey(idx);
                  if (key == null) {
                      break;
                  }
                  buff.append(key).append(": ").append(conn.getHeaderField(idx)).append('\n');
                  ++idx;
              }
          }
  
          StreamManager sm = new StreamManager();
  
          try {
              if (!ignoreBody) {
                  BufferedReader in = (BufferedReader) sm.handle(new BufferedReader(new InputStreamReader(conn.getInputStream())));
                  String inputLine;
                  while ((inputLine = in.readLine()) != null) {
                      buff.append(inputLine);
                  }
                  in.close();
              }
          } finally {
              sm.closeAll();
          }
          return buff.toString();
      }
docs: Parses an http request response
  
  @param conn the connection
  @param includeHeaders if include headers ot not
  @param ignoreBody if ignore body or not
  @return a string representing the received answer
  @throws IOException on any connection