Skip to content

Commit da5a307

Browse files
committed
Fixed for response stubbing with headers for streaming responses.
Fixes amazon-archives/aws-sdk-core-ruby#220
1 parent c32bc08 commit da5a307

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

aws-sdk-core/lib/seahorse/client/plugins/restful_bindings.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def parse_response(response)
6969
status_code = response.context.http_response.status_code
7070
response.data[key] = status_code
7171
when 'header'
72-
response.data[key] = extract_header(headers, shape)
72+
if headers.key?(shape.location_name)
73+
response.data[key] = extract_header(headers, shape)
74+
end
7375
when 'headers'
7476
response.data[key] = extract_header_map(headers, shape)
7577
end

aws-sdk-core/spec/aws/stubbing/stub_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ module ClientStubs
195195

196196
it 'stubs the HTTP response target when with streaming APIs' do
197197
s3 = S3::Client.new(stub_responses: true)
198-
s3.stub_responses(:get_object, { body: 'data' })
198+
s3.stub_responses(:get_object, { body: 'data', content_length: 4 })
199199
io = StringIO.new
200200
resp = s3.get_object(bucket:'bucket', key:'key', response_target: io)
201201
expect(resp.body.read).to eq('data')
202202
expect(resp.body).to be(io)
203203
expect(resp.context.http_response.body).to be(io)
204+
expect(resp.content_length).to eq(4)
204205
end
206+
205207
end
206208
end
207209
end

0 commit comments

Comments
 (0)