Gargi-jais11 commented on code in PR #10586:
URL: https://github.com/apache/ozone/pull/10586#discussion_r3503388894


##########
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:
   @Russole thanks for bringing this in view. Will revert the changes for this 
but now the problem is `test_bucket_list_prefix_unreadable` this test since the 
encoding type is not there so it should not encode it. 
   
   With original :
   ```
   if (prefixSpecified) {
         response.setPrefix(EncodingTypeObject.createNullable(prefix, 
encodingType));
       }
   ```
   **Local test:**
   ```
   bash-5.1$ aws s3api list-objects \
     --bucket buck1 \
     --prefix $'\n' \
     --endpoint-url http://s3g:9878/
   ```
   **Actual is:**
   ```
   {
       "RequestCharged": null,
       "Prefix": "%0A"            --------------------> it is encoded without 
encoding type mentioned in the request
   }
   ```
   
   **Expected :**
   ```
   {
       "RequestCharged": null,
       "Prefix": "\n"
   }
   ```



-- 
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