fix: Omit the Content-Type header for requests without bodies #3338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently if the generated marshaller doesn't set the
Content-Type
header for a given request AND the request uses an HTTP verb that could have a body, we set aContent-Type
header here:aws-sdk-net/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Marshaller.cs
Lines 89 to 98 in 1baa759
This is problematic for at least one service (Connect Outbound Campaigns) that throws
415: Unsupported Media Type
when it receives aContent-Type
for a POST request with no body.Now, instead of setting
Content-Type
based on the verb, we set it based on if the request has a body. I think this is what we intended to do in e6f0f5e, but missed that we have this fallback logic in the core marshaller.Motivation and Context
V1399441092
Testing
Added a new test case to our mock rest-json service to test that a POST without a body doesn't have a
Content-Type
headerTypes of changes
Checklist
License