Skip to content

Commit 04e5691

Browse files
committed
Add ContentLanguage to header collection of GetObjectResponse.
stack-info: PR: #4074, branch: GarrettBeatty/stacked/7
1 parent 1883db9 commit 04e5691

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "S3",
5+
"type": "patch",
6+
"changeLogMessages": [
7+
"Add ContentLanguage to header collection of GetObjectResponse."
8+
]
9+
}
10+
]
11+
}

sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectResponseUnmarshaller.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private static void UnmarshallResult(XmlUnmarshallerContext context,GetObjectRes
8787
response.Headers.ContentEncoding = S3Transforms.ToString(responseData.GetHeaderValue("Content-Encoding"));
8888
if (responseData.IsHeaderPresent("Content-Language"))
8989
response.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
90+
response.Headers.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
9091
if (responseData.IsHeaderPresent("Content-Length"))
9192
response.Headers.ContentLength = long.Parse(responseData.GetHeaderValue("Content-Length"), CultureInfo.InvariantCulture);
9293
if (responseData.IsHeaderPresent("x-amz-object-lock-legal-hold"))

sdk/test/Services/S3/IntegrationTests/GetObjectTests.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,5 +246,50 @@ public void TestContentLanguageResponseHeaderOverride()
246246
"Original ContentLanguage should still be stored when no override is specified");
247247
}
248248
}
249+
250+
[TestMethod]
251+
[TestCategory("S3")]
252+
public void TestContentLanguageHeadersCollection()
253+
{
254+
var key = "TestContentLanguageHeadersCollection";
255+
var expectedLanguage = "de-DE";
256+
257+
// Put object with Content-Language header
258+
var putRequest = new PutObjectRequest
259+
{
260+
BucketName = bucketName,
261+
Key = key,
262+
ContentBody = "Test content for Content-Language headers collection"
263+
};
264+
putRequest.Headers["Content-Language"] = expectedLanguage;
265+
266+
Client.PutObject(putRequest);
267+
268+
// Get object and verify both ContentLanguage properties are set
269+
var response = Client.GetObject(new GetObjectRequest
270+
{
271+
BucketName = bucketName,
272+
Key = key
273+
});
274+
275+
using (response)
276+
{
277+
// Verify the direct ContentLanguage property
278+
Assert.IsNotNull(response.ContentLanguage,
279+
"ContentLanguage property should not be null");
280+
Assert.AreEqual(expectedLanguage, response.ContentLanguage,
281+
"ContentLanguage property should match the value set during PutObject");
282+
283+
// Verify the Headers.ContentLanguage property
284+
Assert.IsNotNull(response.Headers.ContentLanguage,
285+
"Headers.ContentLanguage property should not be null");
286+
Assert.AreEqual(expectedLanguage, response.Headers.ContentLanguage,
287+
"Headers.ContentLanguage property should match the value set during PutObject");
288+
289+
// Verify both properties have the same value
290+
Assert.AreEqual(response.ContentLanguage, response.Headers.ContentLanguage,
291+
"ContentLanguage and Headers.ContentLanguage should have the same value");
292+
}
293+
}
249294
}
250295
}

0 commit comments

Comments
 (0)