-
Notifications
You must be signed in to change notification settings - Fork 874
Content Language Bug Fix #4224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/transfermanager
Are you sure you want to change the base?
Content Language Bug Fix #4224
Conversation
stack-info: PR: #4224, branch: GarrettBeatty/gcbeatty/taskoptimization/5
2750531 to
c331621
Compare
stack-info: PR: #4224, branch: GarrettBeatty/gcbeatty/taskoptimization/5
c331621 to
e073b2e
Compare
stack-info: PR: #4224, branch: GarrettBeatty/gcbeatty/taskoptimization/5
e073b2e to
f6c7aee
Compare
stack-info: PR: #4224, branch: GarrettBeatty/gcbeatty/taskoptimization/5
89431b0 to
0ad16d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a Content-Language header handling issue that caused signature mismatch errors in S3 requests. The root cause was that the SDK signed requests with Content-Language but didn't actually send the header because it wasn't properly configured as a content header in HttpClient. The PR also standardizes GetObjectMetadataResponse.ContentLanguage to use the Headers collection as its backing store, matching the pattern used in GetObjectResponse.
Key Changes:
- Added Content-Language to the list of content headers in HttpRequestMessageFactory so it's correctly placed on HttpContent.Headers
- Refactored GetObjectMetadataResponse.ContentLanguage to delegate to Headers.ContentLanguage instead of using a private field
- Added integration test to verify Content-Language header is correctly sent and retrieved
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/src/Core/Amazon.Util/HeaderKeys.cs | Added ContentLanguageHeader constant for consistent header name reference |
| sdk/src/Core/Amazon.Runtime/Pipeline/HttpHandler/_netstandard/HttpRequestMessageFactory.cs | Added Content-Language to ContentHeaderNames HashSet and WriteContentHeaders method to fix signing/sending mismatch |
| sdk/src/Services/S3/Generated/Model/GetObjectMetadataResponse.cs | Removed auto-generated ContentLanguage property and private field (moved to custom implementation) |
| sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/GetObjectMetadataResponseUnmarshaller.cs | Removed auto-generated unmarshalling code for ContentLanguage (moved to custom implementation) |
| sdk/src/Services/S3/Custom/Model/GetObjectMetadataResponse.cs | Added custom ContentLanguage property that delegates to Headers.ContentLanguage |
| sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectMetadataResponseUnmarshaller.cs | Added custom unmarshalling code that populates Headers.ContentLanguage |
| generator/ServiceModels/s3/s3.customizations.json | Excluded ContentLanguage from HeadObjectOutput generation to enable custom implementation |
| sdk/test/Services/S3/IntegrationTests/PutObjectTests.cs | Added integration test verifying Content-Language header round-trip through PutObject and GetObject/GetObjectMetadata |
| generator/.DevConfigs/19ed68ce-9f46-4e1e-a0ff-45a2b3641947.json | Dev config with patch version bump and changelog message |
generator/.DevConfigs/19ed68ce-9f46-4e1e-a0ff-45a2b3641947.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
This PR fixes two issues related to the
Content-LanguageHTTP header in the AWS SDK for .NET:Request Signing Issue: The
Content-Languageheader was not properly handled as a content header inHttpRequestMessageFactory, causing signature mismatch errors. This was is also happening ondevelopmentbranch too.GetObjectMetadataResponse Backing Field Consistency: Changed
GetObjectMetadataResponse.ContentLanguageto useHeaders.ContentLanguageas the backing field, matching the pattern used byGetObjectResponse.ContentLanguage.Request Signing Fix
Symptom:
When setting
Content-Languageon a PutObject request, the SDK throwsSignatureDoesNotMatch:Root Cause:
The SDK includes
Content-Languagein signature calculation, but .NET'sHttpClientwasn't actually sending it because the header wasn't being placed onHttpContent.Headers.Evidence from AWS error response:
content-language:en-UScontent-language:(empty)The
Content-Languageheader value was lost because:HttpWebRequestMessage.ContentHeaderNamesdidn't includeContent-LanguageSetRequestHeaders()attempted to add it toHttpRequestMessage.Headers(request headers)Content-Languageis a content header - .NET'sHttpClientrejects it as a request headerWriteContentHeaders()had no code to addContent-LanguagetoHttpContent.HeadersFix:
HeaderKeys.ContentLanguageHeadertoContentHeaderNamesHashSetContent-Languagehandling inWriteContentHeaders()methodGetObjectMetadataResponse Backing Field Fix
Changed
GetObjectMetadataResponse.ContentLanguageto delegate toHeaders.ContentLanguageas the backing store instead of a private field, matching the pattern inGetObjectResponse.ContentLanguage.Testing
Checklist
License