protected String getCanonicalizedEndpoint(URI endpoint) {
        String endpointForStringToSign = StringUtils.lowerCase(endpoint.getHost());
        /*
         * Apache HttpClient will omit the port in the Host header for default
         * port values (i.e. 80 for HTTP and 443 for HTTPS) even if we
         * explicitly specify it, so we need to be careful that we use the same
         * value here when we calculate the string to sign and in the Host
         * header we send in the HTTP request.
         */
        if (SdkHttpUtils.isUsingNonDefaultPort(endpoint)) {
            endpointForStringToSign += ":" + endpoint.getPort();
        }

        return endpointForStringToSign;
    }
This method takes in a resourcePath and canonicalizes it by adding an initial slash ("\") if
that isn't already present. Trailing slashes are preserved.

If urlEncode is true, the path is also urlEncoded (double url encoding) and normalized.
The urlEncoding will preserve the slash character. Normalization collapses paths with
dots according to RFC 3986.

@param resourcePath a path that may be urlEncoded
@param urlEncode true if canonicalization should include double url encode
@return the canonical path
aws-java-sdk-core/src/main/java/com/amazonaws/auth/AbstractAWSSigner.java