public String handleUnexpectedStatusCode(
      HttpURLConnection connection, int statusCode, String errorStr) throws IOException {
    // We do no handle anything but OK for now. Again, we need a real client for this API.
    // TODO: handle 401 and return a new connection? nothing for now
    InputStream errorStream = connection.getErrorStream();
    String error = "Received " + statusCode + (errorStr == null ? "" : (" (" + errorStr + ")"));
    if (errorStream != null) {
      error += ": " + IOUtils.toString(errorStream);
    } else {
      errorStream = connection.getInputStream();
      if (errorStream != null) {
        error += ": " + IOUtils.toString(errorStream);
      }
    }
    return error;
  }
Gets the Hadoop kerberos secure connection (not an SSL connection).
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/YarnQueueHelper.java