Skip to content

Conversation

@GarrettBeatty
Copy link
Contributor

@GarrettBeatty GarrettBeatty commented Nov 26, 2025

no dev config since its already in #4074

Description

update the backing field for content language to be in the headers instead so that for TransferUtilityDownloadResponse we can easily just copy the headers only instead of the response.ContentLanguage field.

Also was a bug in #4074 where it was always setting the content language in one case because the if statement didnt have brackets. So this fixes that bug and also makes it so the headers is the backing field

Motivation and Context

Testing

  1. unit tests pass
  2. need to run dry run

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@GarrettBeatty GarrettBeatty marked this pull request as ready for review November 26, 2025 19:49
{
return this._contentLanguage != null;
get { return this.Headers.ContentLanguage; }
set { this.Headers.ContentLanguage = value; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Get-Only: Guaranteed Single Instance

When Headers is get-only, you're guaranteed that there is exactly one HeadersCollection instance throughout the lifetime of the GetObjectResponse object:

var response = new GetObjectResponse();

// First access - creates the HeadersCollection
response.ContentLanguage = "en-US";
// Internally: response.Headers.ContentLanguage = "en-US"
//            ↓ This calls the getter, which creates headersCollection once

// Later access - uses THE SAME HeadersCollection
response.Headers.ContentType = "text/html";
//       ↑ Returns the same headersCollection instance

// Even later
Console.WriteLine(response.ContentLanguage); // "en-US" ✓
// Still reading from the SAME headersCollection instance

@GarrettBeatty GarrettBeatty changed the title Fix content language initialization Fix content language initialization and update to use headers backing field Nov 26, 2025
if (responseData.IsHeaderPresent("Content-Encoding"))
response.Headers.ContentEncoding = S3Transforms.ToString(responseData.GetHeaderValue("Content-Encoding"));
if (responseData.IsHeaderPresent("Content-Language"))
response.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are still marshalling response.ContentLanguage somewhere though right?

@GarrettBeatty GarrettBeatty merged commit da1fc1e into feature/transfermanager Nov 26, 2025
7 checks passed
@GarrettBeatty GarrettBeatty deleted the gcbeatty/contentlanguagefix2 branch November 26, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants