AwsInterceptor icon indicating copy to clipboard operation
AwsInterceptor copied to clipboard

Interceptor adds a Slash "/" after the endpoint

Open chougule-akshay opened this issue 10 months ago • 0 comments

Url: https://www.aws.com/api

Once the request is signed using the interceptor -

Excepted: https://www.aws.com/api

Current: https://www.aws.com/api/

Solution:

private fun Request.sign(): Request {
    val canonicalUrl = url.canonicalized()
    val awsDummyRequest = DefaultRequest<Any>(serviceName).apply {

        ****endpoint = url.host
        resourcePath = url.resource****  //separate out the host and resource

        httpMethod = HttpMethodName.valueOf(method)
        setQueryParams(canonicalUrl)
        setBody(body)
    }
    signer.sign(awsDummyRequest, credentialsProvider.credentials)
    return newBuilder()
        .url(canonicalUrl)
        .applyAwsHeaders(awsDummyRequest.headers)
        .build()}

chougule-akshay avatar Apr 02 '24 18:04 chougule-akshay