code: int getContentLength(HttpURLConnection conn) {
      String transferEncoding = conn.getHeaderField(TRANSFER_ENCODING);
      if (transferEncoding == null || transferEncoding.equalsIgnoreCase("chunked")) {
        return conn.getHeaderFieldInt(CONTENT_LENGTH, -1);
      } else {
        return -1;
      }
    }
docs: /* read response content length from server