Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ private ResponseEntity<StreamingResponseBody> getObjectWithRange(
var contentLength = endInclusive - startInclusive + 1;

if (contentLength < 0 || fileSize <= startInclusive) {
return ResponseEntity.status(REQUESTED_RANGE_NOT_SATISFIABLE).build();
throw S3Exception.INVALID_RANGE;
}

return ResponseEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE;

import com.adobe.testing.s3mock.dto.ErrorResponse;
import org.springframework.http.HttpStatus;
Expand All @@ -32,6 +33,8 @@
public class S3Exception extends RuntimeException {
private static final String INVALID_REQUEST_CODE = "InvalidRequest";
private static final String BAD_REQUEST_CODE = "BadRequest";
private static final String REQUESTED_RANGE_NOT_SATISFIABLE_CODE = "InvalidRange";

public static final S3Exception INVALID_PART_NUMBER =
new S3Exception(BAD_REQUEST.value(), "InvalidArgument",
"Part number must be an integer between 1 and 10000, inclusive");
Expand Down Expand Up @@ -119,6 +122,10 @@ public static S3Exception completeRequestMissingChecksum(String algorithm, Integ
+ "changing the object's metadata, storage class, website redirect location or "
+ "encryption attributes.");

public static final S3Exception INVALID_RANGE =
new S3Exception(REQUESTED_RANGE_NOT_SATISFIABLE.value(), REQUESTED_RANGE_NOT_SATISFIABLE_CODE,
"Invalid http range.");

public static final S3Exception BAD_REQUEST_MD5 =
new S3Exception(BAD_REQUEST.value(), BAD_REQUEST_CODE,
"Content-MD5 does not match object md5");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ internal class ObjectControllerTest : BaseControllerTest() {
.header("Range", "bytes=9999999-10000000")
)
.andExpect(status().isRequestedRangeNotSatisfiable)
.andExpect(content().string(MAPPER.writeValueAsString(from(S3Exception.INVALID_RANGE))))
}

@Test
Expand Down