code: public static String constructUrl(final HttpServerExchange exchange, final String path) {
          final HeaderMap headers = exchange.getRequestHeaders();
          String host = headers.getFirst(HOST);
          String protocol = exchange.getConnection().getSslSessionInfo() != null ? "https" : "http";
  
          return protocol + "://" + host + path;
      }
docs: Based on the current request represented by the HttpExchange construct a complete URL for the supplied path.
  
  @param exchange - The current HttpExchange
  @param path - The path to include in the constructed URL
  @return The constructed URL