aws / aws-sdk-cpp

AWS SDK for C++
Apache License 2.0
1.97k stars 1.06k forks source link

WriteGetObjectResponseRequest: Content-Type #2035

Open scottpakula opened 2 years ago

scottpakula commented 2 years ago

Describe the bug

I have ran into an issue with 1.9.220 of the aws-sdk-cpp when using the WriteGetObjectResponseRequest and attempting to configure the Content-Type. When setting it . When reviewing the issues, I had found: WriteGetObjectResponseRequest: Content-Type #1665, but the ticket was already closed. I would like reopen it.

Expected Behavior

I'd like to set the content-type to be something other than just "text/plain"

Current Behavior

The content-type is always text/plain

Reproduction Steps

  S3::Model::WriteGetObjectResponseRequest request;
  request.WithRequestRoute(route);
  request.WithRequestToken(token);
  request.SetBody(objectStream);
  request.SetContentType("application/json"); // <-- curl -v show "text/plain" instead
  auto outcome = client.WriteGetObjectResponse(request);

Possible Solution

N/A

Additional Information/Context

No response

AWS CPP SDK version used

1.9.220

Compiler and Version used

9.4.0

Operating System and version

Ubuntu Linux 20.04

scottpakula commented 3 weeks ago

It seems that the root cause of this issue is that Content-Type is simply not set in aws-cpp-sdk-s3/source/model/WriteGetObjectResponseRequest.cpp. I patched in the following to correct the issue: { ss << GetContentType(); headers.emplace("x-amz-fwd-header-content-type", ss.str()); ss.str(""); }