Russole commented on code in PR #10586:
URL: https://github.com/apache/ozone/pull/10586#discussion_r3499999214


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java:
##########
@@ -157,17 +159,21 @@ Response handleGetRequest(S3RequestContext context, 
String bucketName) throws IO
     if (encodingType != null && !encodingType.equals(ENCODING_TYPE)) {
       throw S3ErrorTable.newError(S3ErrorTable.INVALID_ARGUMENT, encodingType);
     }
-
     // If you specify the encoding-type request parameter,should return
-    // encoded key name values in the following response elements:
-    //   Delimiter, Prefix, Key, and StartAfter.
+    // encoded key name values in the following response elements: Delimiter,
+    // Key, and StartAfter. The echoed Prefix request parameter is returned 
without URL encoding.
     //
     // For detail refer:
     // 
https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#AmazonS3-ListObjectsV2-response-EncodingType
     ListObjectResponse response = new ListObjectResponse();
-    response.setDelimiter(EncodingTypeObject.createNullable(delimiter, 
encodingType));
+    // AWS omits Delimiter from the response when the client passes delimiter= 
or does not specify delimiter at all.
+    if (StringUtils.isNotEmpty(delimiter)) {
+      response.setDelimiter(EncodingTypeObject.createNullable(delimiter, 
encodingType));
+    }
     response.setName(bucketName);
-    response.setPrefix(EncodingTypeObject.createNullable(prefix, 
encodingType));
+    if (prefixSpecified) {
+      response.setPrefix(EncodingTypeObject.createNullable(prefix, null));
+    }

Review Comment:
   `Prefix` should also be encoded when `encoding-type=url` is specified.
   
   AWS docs say `EncodingType` applies to `Delimiter`, `Prefix`, `Key`, and 
`StartAfter`:
   
https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#AmazonS3-ListObjectsV2-response-EncodingType
   
   Local test:
   
   ```bash
   aws s3api list-objects \
     --bucket buck1 \
     --prefix $'\n' \
     --encoding-type url \
     --endpoint-url http://localhost:9878/
   ```
   
   Actual:
   
   ```json
   "Prefix": "\n"
   ```
   
   Expected:
   
   ```json
   "Prefix": "%0A"
   ```
   
   Looks like `Prefix` is created with a `null` encoding type here. Should this 
use `encodingType` instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to