private void replaceHost(Request<?> request, String newHost) {
        URI currentEndpoint = request.getEndpoint();
        try {
            request.setEndpoint(new URI(currentEndpoint.getScheme(),
                                        currentEndpoint.getUserInfo(),
                                        newHost,
                                        currentEndpoint.getPort(),
                                        currentEndpoint.getPath(),
                                        currentEndpoint.getQuery(),
                                        currentEndpoint.getFragment()));
        } catch (URISyntaxException e) {
            throw new IllegalStateException(e);
        }
    }
{@link RequestHandler2} that modifies the endpoint to handle virtual addressing (account id hoisting),
Dual-Stack, and FIPS.
aws-java-sdk-s3control/src/main/java/com/amazonaws/services/s3control/internal/handlers/EndpointHandler.java