Skip to content

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