Skip to content

Commit dc61076

Browse files
committed
Review
1 parent 8268327 commit dc61076

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/fixtures/s3-fixture/src/main/java/fixture/s3/S3HttpHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,18 @@ public S3HttpHandler(final String bucket, @Nullable final String basePath) {
7878
this.bucketAndBasePath = bucket + (Strings.hasText(basePath) ? "/" + basePath : "");
7979
}
8080

81-
private static final Set<String> NO_REQUEST_BODY_METHODS = Set.of("GET", "HEAD", "DELETE");
81+
/**
82+
* Requests using these HTTP methods never have a request body (this is checked in the handler).
83+
*/
84+
private static final Set<String> METHODS_HAVING_NO_REQUEST_BODY = Set.of("GET", "HEAD", "DELETE");
8285

8386
@Override
8487
public void handle(final HttpExchange exchange) throws IOException {
8588
// Remove custom query parameters before processing the request. This simulates how S3 ignores them.
8689
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/LogFormat.html#LogFormatCustom
8790
final S3Request request = parseRequest(exchange);
8891

89-
if (NO_REQUEST_BODY_METHODS.contains(request.method())) {
92+
if (METHODS_HAVING_NO_REQUEST_BODY.contains(request.method())) {
9093
int read = exchange.getRequestBody().read();
9194
assert read == -1 : "Request body should have been empty but saw [" + read + "]";
9295
}
@@ -569,7 +572,7 @@ private boolean isUnderBucketRootAndBasePath() {
569572
}
570573

571574
public boolean isHeadObjectRequest() {
572-
return "HEAD".equals(method) && path.startsWith("/" + S3HttpHandler.this.bucketAndBasePath + "/");
575+
return "HEAD".equals(method) && isUnderBucketRootAndBasePath();
573576
}
574577

575578
public boolean isListMultipartUploadsRequest() {

0 commit comments

Comments
 (0)