private String getCanonicalizedResourcePath(SignableRequest<?> request) {
        String resourcePath = "";

        if (request.getEndpoint().getPath() != null) {
            resourcePath += request.getEndpoint().getPath();
        }

        if (request.getResourcePath() != null) {
            if (resourcePath.length() > 0 &&
                !resourcePath.endsWith("/") &&
                !request.getResourcePath().startsWith("/")) {
                resourcePath += "/";
            }

            resourcePath += request.getResourcePath();
        } else if (!resourcePath.endsWith("/")) {
            resourcePath += "/";
        }

        if (!resourcePath.startsWith("/")) {
            resourcePath = "/" + resourcePath;
        }

        if (resourcePath.startsWith("//")) {
            resourcePath = resourcePath.substring(1);
        }

        return resourcePath;
    }
Calculate string to sign for signature version 2.

@param request
           The request being signed.

@return String to sign

@throws SdkClientException
            If the string to sign cannot be calculated.
aws-java-sdk-core/src/main/java/com/amazonaws/auth/QueryStringSigner.java