From 04e5691bbab7e7d8109010a1287fe25783d6e1c1 Mon Sep 17 00:00:00 2001 From: Garrett Beatty Date: Thu, 23 Oct 2025 13:32:12 -0400 Subject: [PATCH] Add ContentLanguage to header collection of GetObjectResponse. stack-info: PR: https://github.com/aws/aws-sdk-net/pull/4074, branch: GarrettBeatty/stacked/7 --- .../c49077d9-90b3-437f-b316-6d8d8833ae72.json | 11 +++++ .../GetObjectResponseUnmarshaller.cs | 1 + .../S3/IntegrationTests/GetObjectTests.cs | 45 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 generator/.DevConfigs/c49077d9-90b3-437f-b316-6d8d8833ae72.json diff --git a/generator/.DevConfigs/c49077d9-90b3-437f-b316-6d8d8833ae72.json b/generator/.DevConfigs/c49077d9-90b3-437f-b316-6d8d8833ae72.json new file mode 100644 index 000000000000..ee368d5cf126 --- /dev/null +++ b/generator/.DevConfigs/c49077d9-90b3-437f-b316-6d8d8833ae72.json @@ -0,0 +1,11 @@ +{ + "services": [ + { + "serviceName": "S3", + "type": "patch", + "changeLogMessages": [ + "Add ContentLanguage to header collection of GetObjectResponse." + ] + } + ] +} diff --git a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectResponseUnmarshaller.cs b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectResponseUnmarshaller.cs index 410f93fd4342..171aebac022e 100644 --- a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectResponseUnmarshaller.cs +++ b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectResponseUnmarshaller.cs @@ -87,6 +87,7 @@ private static void UnmarshallResult(XmlUnmarshallerContext context,GetObjectRes response.Headers.ContentEncoding = S3Transforms.ToString(responseData.GetHeaderValue("Content-Encoding")); if (responseData.IsHeaderPresent("Content-Language")) response.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language")); + response.Headers.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language")); if (responseData.IsHeaderPresent("Content-Length")) response.Headers.ContentLength = long.Parse(responseData.GetHeaderValue("Content-Length"), CultureInfo.InvariantCulture); if (responseData.IsHeaderPresent("x-amz-object-lock-legal-hold")) diff --git a/sdk/test/Services/S3/IntegrationTests/GetObjectTests.cs b/sdk/test/Services/S3/IntegrationTests/GetObjectTests.cs index 6cba8fc6b989..f4c8c103e126 100644 --- a/sdk/test/Services/S3/IntegrationTests/GetObjectTests.cs +++ b/sdk/test/Services/S3/IntegrationTests/GetObjectTests.cs @@ -246,5 +246,50 @@ public void TestContentLanguageResponseHeaderOverride() "Original ContentLanguage should still be stored when no override is specified"); } } + + [TestMethod] + [TestCategory("S3")] + public void TestContentLanguageHeadersCollection() + { + var key = "TestContentLanguageHeadersCollection"; + var expectedLanguage = "de-DE"; + + // Put object with Content-Language header + var putRequest = new PutObjectRequest + { + BucketName = bucketName, + Key = key, + ContentBody = "Test content for Content-Language headers collection" + }; + putRequest.Headers["Content-Language"] = expectedLanguage; + + Client.PutObject(putRequest); + + // Get object and verify both ContentLanguage properties are set + var response = Client.GetObject(new GetObjectRequest + { + BucketName = bucketName, + Key = key + }); + + using (response) + { + // Verify the direct ContentLanguage property + Assert.IsNotNull(response.ContentLanguage, + "ContentLanguage property should not be null"); + Assert.AreEqual(expectedLanguage, response.ContentLanguage, + "ContentLanguage property should match the value set during PutObject"); + + // Verify the Headers.ContentLanguage property + Assert.IsNotNull(response.Headers.ContentLanguage, + "Headers.ContentLanguage property should not be null"); + Assert.AreEqual(expectedLanguage, response.Headers.ContentLanguage, + "Headers.ContentLanguage property should match the value set during PutObject"); + + // Verify both properties have the same value + Assert.AreEqual(response.ContentLanguage, response.Headers.ContentLanguage, + "ContentLanguage and Headers.ContentLanguage should have the same value"); + } + } } }