protected HttpURLConnection openConnection(String endpoint, String credentials)
    throws IOException {
    URL url = new URL(getServerURL(server) + endpoint);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    if (credentials != null) {
      conn.setRequestProperty("Authorization", getBasicAuthHeader(credentials));
    }
    return conn;
  }
Opens an HTTP connection to the specified endpoint with optional Basic Authentication.
@param endpoint    the endpoint to connect to
@param credentials the credentials for Basic Authentication (optional)
@return the opened HttpURLConnection
@throws IOException if an error occurs while opening the connection
hbase-http/src/test/java/org/apache/hadoop/hbase/http/LdapServerTestBase.java