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 ; }
Based on the current request represented by the HttpExchange construct a complete URL for the supplied path .