Skip to content

Commit

Permalink
Fix Presigner not respecting :endpoint URL scheme
Browse files Browse the repository at this point in the history
When presigned URL is generated for a client which has `:endpoint`, the
URL scheme was always "https", even when the `:endpoint` had "http"
scheme.
  • Loading branch information
janko committed Dec 11, 2015
1 parent 2902835 commit f0d2cf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aws-sdk-core/lib/aws-sdk-core/s3/presigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def presigned_url(method, params = {})
private

def http_scheme(params, virtual_host)
if params.delete(:secure) == false || virtual_host
secure = params.delete(:secure)

if @client.config.endpoint.host != "s3.amazonaws.com"
@client.config.endpoint.scheme
elsif secure == false || virtual_host
'http'
else
'https'
Expand Down
10 changes: 10 additions & 0 deletions aws-sdk-core/spec/aws/s3/presigner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ module S3
expect(url).to match(/^http:/)
end

it 'uses the correct :endpoint scheme' do
client.config.endpoint = URI("http://example.com")
signer = Presigner.new(client: client)
url = signer.presigned_url(:get_object,
bucket:'aws-sdk',
key:'foo',
)
expect(url).to match(/^http:/)
end

end
end
end
Expand Down

0 comments on commit f0d2cf8

Please sign in to comment.