private InputStream getInputStream(String path, String requestMethod, Map<String, String> headers
                                     , byte[] body) throws IOException, AmbariHttpException {
    // add the Ambari session cookie to the given headers
    String sessionId = ambariSessionManager.getCurrentSessionId();
    if (sessionId != null) {

      String ambariSessionCookie = ambariSessionManager.getSessionCookie() + "=" + sessionId;

      if (headers == null || headers.isEmpty()) {
        headers = Collections.singletonMap(URLStreamProvider.COOKIE, ambariSessionCookie);
      } else {
        headers = new HashMap<>(headers);

        String cookies = headers.get(URLStreamProvider.COOKIE);

        headers.put(URLStreamProvider.COOKIE, URLStreamProvider.appendCookie(cookies, ambariSessionCookie));
      }
    }

    // adapt the headers for the internal URLStreamProvider signature
    Map<String, List<String>> headerMap = new HashMap<>();
    for (Map.Entry<String, String> entry : headers.entrySet()) {
      headerMap.put(entry.getKey(), Collections.singletonList(entry.getValue()));
    }

    return getInputStream(streamProvider.processURL(controller.getAmbariServerURI(path.startsWith("/") ? path : "/" + path),
        requestMethod, body, headerMap));
  }
Construct a view Ambari stream provider.

@param streamProvider        the underlying stream provider
@param ambariSessionManager  the Ambari session manager
@param controller         the Ambari configuration

@throws IllegalStateException if the Ambari stream provider can not be created
ambari-server/src/main/java/org/apache/ambari/server/view/ViewAmbariStreamProvider.java