private void sendBrowserMsg(Socket socket, boolean success) throws IOException {
    PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

    List<String> content = new ArrayList<>();
    content.add("HTTP/1.0 200 OK");
    content.add("Content-Type: text/html");
    String responseText;
    if (success) {
      responseText =
          "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"/>"
              + "<title>SAML Response Received</title></head>"
                  + "<body onload=\"waitAndClose()\">Successfully authenticated. You may close this window.</body>" +
                  "<script>" +
                  "  function waitAndClose() {" +
                  "    setTimeout(function() {" +
                  "      window.close()" +
                  "    }, 100);" +
                  "  }" +
                  "</script>"+"</html>";
    } else {
      responseText =
          "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"/>"
              + "<title>SAML Response Received</title></head>"
              + "<body>Authentication failed. Please check server logs for details."
              + " You may close this window.</body></html>";
    }
    content.add(String.format("Content-Length: %s", responseText.length()));
    content.add("");
    content.add(responseText);

    for (int i = 0; i < content.size(); ++i) {
      if (i > 0) {
        out.print("\r\n");
      }
      out.print(content.get(i));
    }
    out.flush();
  }
Waits for a server response until the given timeout value in milliseconds.
Returns null if timeout.
jdbc/src/java/org/apache/hive/jdbc/saml/HiveJdbcBrowserClient.java