public static URI createUriFromRequest(DiscFilterRequest request, String path, Optional<String> hostOverride) {
        try {
            // Prefer local port as observed by client over local listen port
            int port = Optional.ofNullable((Integer)request.getAttribute(RequestUtils.JDICS_REQUEST_PORT))
                    .orElse(request.getUri().getPort());
            String host = hostOverride.orElse(request.getServerName());
            return new URI(request.getScheme(), null, host, port, path, null, null);
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
Helper methods for auth0/okta request filters.

@author valerijf
container-core/src/main/java/com/yahoo/jdisc/http/filter/util/FilterUtils.java