diff --git a/aws-sdk-core/lib/seahorse/client/plugins/restful_bindings.rb b/aws-sdk-core/lib/seahorse/client/plugins/restful_bindings.rb index 160eb949825..38065ab533e 100644 --- a/aws-sdk-core/lib/seahorse/client/plugins/restful_bindings.rb +++ b/aws-sdk-core/lib/seahorse/client/plugins/restful_bindings.rb @@ -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 diff --git a/aws-sdk-core/spec/aws/stubbing/stub_spec.rb b/aws-sdk-core/spec/aws/stubbing/stub_spec.rb index 122ec09375a..22ca9dcb333 100644 --- a/aws-sdk-core/spec/aws/stubbing/stub_spec.rb +++ b/aws-sdk-core/spec/aws/stubbing/stub_spec.rb @@ -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