From d489120e64f692e64ef17461212f7113564e8cfb Mon Sep 17 00:00:00 2001 From: Gustavo Perdomo Date: Fri, 16 Nov 2018 11:40:50 -0300 Subject: [PATCH] Fix resigned url to include port Fix to able to use presigned url with minio --- Sources/S3Signer/S3Signer+Private.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/S3Signer/S3Signer+Private.swift b/Sources/S3Signer/S3Signer+Private.swift index 03bf1dc..d06ca51 100755 --- a/Sources/S3Signer/S3Signer+Private.swift +++ b/Sources/S3Signer/S3Signer+Private.swift @@ -127,7 +127,18 @@ extension S3Signer { let region = region ?? config.region - updatedHeaders["host"] = url.host ?? region.host + var hostname: String + + if let host = url.host { + hostname = host + if let port = url.port { + hostname = hostname + ":\(port)" + } + } else { + hostname = region.host + } + + updatedHeaders["host"] = hostname let (canonRequest, fullURL) = try presignedURLCanonRequest(httpMethod, dates: dates, expiration: expiration, url: url, region: region, headers: updatedHeaders)