rich7420 commented on code in PR #11675:
URL: https://github.com/apache/ozone/pull/11675#discussion_r4345365879


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/RangeHeaderParserUtil.java:
##########
@@ -56,10 +57,19 @@ public static RangeHeader parseRangeHeader(String 
rangeHeaderVal, long
       if (!matcher.group("end").equals("")) {
         end = Long.parseLong(matcher.group("end"));
       } else {
+        noEnd = true;
         end = length - 1;
       }
-      if (noStart) {
-        if (end < length) {
+      if (noStart && noEnd) {
+        // "bytes=-" has neither a first byte nor a suffix length, so it is 
ignored.
+        start = 0;
+        end = length - 1;
+        readFull = true;
+      } else if (noStart) {
+        if (end == 0 || length == 0) {

Review Comment:
   Just curious, did AWS return 416 for empty `bytes=-5`? [RFC 9110 
ยง14.1.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-14.1.2) reads as 
if it would be satisfiable, so I wanted to double-check.



##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectGet.java:
##########
@@ -335,6 +336,22 @@ public void getRangeHeader() throws IOException, 
OS3Exception {
     assertNull(response.getHeaderString(TAG_COUNT_HEADER));
   }
 
+  @Test
+  public void getUnsatisfiableOrMalformedRange() throws IOException, 
OS3Exception {

Review Comment:
   nit: please also cover HEAD in `TestObjectHead#rangeCases`:
   ```java
           Arguments.of("bytes=-", HttpStatus.SC_OK, 10L, null)
   ```



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/RangeHeaderParserUtil.java:
##########
@@ -68,7 +78,7 @@ public static RangeHeader parseRangeHeader(String 
rangeHeaderVal, long
       } else {
         if (start >= length)  {
           readFull = true;
-          if (end >= length) {
+          if (end >= length || noEnd) {

Review Comment:
   nit: `bytes=0-` on an empty object also changes from 200 to 416 here (same 
as S3, see NIFI-9055). Please add it to the table in the description.



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