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


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3Utils.java:
##########
@@ -62,6 +62,17 @@ public static String urlEncode(String str)
     return URLEncoder.encode(str, UTF_8.name());
   }
 
+  /**
+   * Percent-encode a string for S3 {@code encoding-type=url} responses.
+   *
+   * <p>Unlike {@link URLEncoder} (application/x-www-form-urlencoded), AWS S3
+   * uses percent-encoding where spaces are {@code %20}, not {@code +}.
+   */
+  public static String s3urlEncode(String str)
+      throws UnsupportedEncodingException {
+    return urlEncode(str).replace("+", "%20");
+  }

Review Comment:
   @adoroszlai 
   On the basis of local testing I found that`PercentCodec` alone does not 
encode ASCII specials like **=,** which S3 requires. Using it correctly needs 
configuring **alwaysEncodeChars** to mirror URLEncoder's unsafe set. Since the 
only S3 difference from URLEncoder is %20 vs +, urlEncode(str).replace("+", 
"%20") is simpler and equivalent. 
   



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