Skip to content

Commit

Permalink
Fixed for response stubbing with headers for streaming responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorrowe committed May 22, 2015
1 parent c32bc08 commit da5a307
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion aws-sdk-core/lib/seahorse/client/plugins/restful_bindings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def parse_response(response)
status_code = response.context.http_response.status_code
response.data[key] = status_code
when 'header'
response.data[key] = extract_header(headers, shape)
if headers.key?(shape.location_name)
response.data[key] = extract_header(headers, shape)
end
when 'headers'
response.data[key] = extract_header_map(headers, shape)
end
Expand Down
4 changes: 3 additions & 1 deletion aws-sdk-core/spec/aws/stubbing/stub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ module ClientStubs

it 'stubs the HTTP response target when with streaming APIs' do
s3 = S3::Client.new(stub_responses: true)
s3.stub_responses(:get_object, { body: 'data' })
s3.stub_responses(:get_object, { body: 'data', content_length: 4 })
io = StringIO.new
resp = s3.get_object(bucket:'bucket', key:'key', response_target: io)
expect(resp.body.read).to eq('data')
expect(resp.body).to be(io)
expect(resp.context.http_response.body).to be(io)
expect(resp.content_length).to eq(4)
end

end
end
end
Expand Down

0 comments on commit da5a307

Please sign in to comment.