private static Object httpResponse(HttpURLConnection con) throws IOException {
    int responseCode = con.getResponseCode();
    InputStream responseStream = con.getErrorStream();
    if (responseStream == null) {
      try {
        responseStream = con.getInputStream();
      } catch (IOException e) {
        return new ServerResponse(responseCode, e.getMessage());
      }
    }
    if (responseStream != null) {
      try (BufferedReader reader = new BufferedReader(
              new InputStreamReader(responseStream, StandardCharsets.UTF_8))) {
        // if not strictly ok, check we are still receiving a JSON
        if (responseCode != HttpServletResponse.SC_OK) {
          String contentType = con.getContentType();
          if (contentType == null || !contentType.contains("application/json")) {
            String line;
            StringBuilder response = new StringBuilder("error " + responseCode + ":");
            while ((line = reader.readLine()) != null) response.append(line);
            return new ServerResponse(responseCode, response.toString());
          }
        }
        // there might be no answer which is still ok
        Object r = reader.ready() ? deserialize(reader) : new HashMap<>(1);
        if (r instanceof Map) {
          ((Map<String, Object>) r).put("status", responseCode);
        }
        return r;
      }
    }
    return responseCode;
}
Performs an http client call.
@param jwt a JWT bearer token (can be null)
@param url the url to call
@param method the http method to use
@param json whether the call is application/json (true) or application/x-www-form-urlencoded (false)
@param arg the query argument
@return the (JSON) response
@throws IOException
standalone-metastore/metastore-rest-catalog/src/test/java/org/apache/iceberg/rest/HMSTestBase.java