Skip to content

Honor EncodingType in response with ListObjectsV2 as with ListObjects #2918

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nanawel
Copy link

@nanawel nanawel commented May 9, 2024

There seems to be a bug with ListObjectsV2 when dealing with type encoding in responses. The special middleware that's responsible for url-decoding the values in some nodes can only be triggered with ListObjects, so in V2 the client ends up with URL-encoded strings that are not valid in the rest of the application.

private function getEncodingTypeMiddleware()
{
return static function (callable $handler) {
return function (Command $command, $request = null) use ($handler) {
$autoSet = false;
if ($command->getName() === 'ListObjects'
&& empty($command['EncodingType'])
) {
$command['EncodingType'] = 'url';
$autoSet = true;
}

This patch should fix this issue while keeping compatibility with PHP 7.

@stobrien89 stobrien89 closed this Mar 14, 2025
@stobrien89 stobrien89 reopened this Mar 14, 2025
Copy link
Member

@stobrien89 stobrien89 left a comment

Choose a reason for hiding this comment

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

Apologies for the very delayed response. Just a minor change and test requested

@@ -785,7 +785,7 @@ private function getEncodingTypeMiddleware()
return static function (callable $handler) {
return function (Command $command, $request = null) use ($handler) {
$autoSet = false;
if ($command->getName() === 'ListObjects'
if (strpos($command->getName(), 'ListObjects') === 0
Copy link
Member

Choose a reason for hiding this comment

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

Can we change this to a str_starts_with()?

Copy link
Member

Choose a reason for hiding this comment

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

Could you either turn this test into a parameterized test which call both listObjects and listObjectsV2 or create a separate unit test for listObjectsV2?

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.

2 participants