Skip to content

Commit 5aed2eb

Browse files
committed
Handle missing delimiter
1 parent c7bace9 commit 5aed2eb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,11 @@ public void handle(final HttpExchange exchange) throws IOException {
231231

232232
} else if (request.isPutObjectRequest()) {
233233
// a copy request is a put request with a copy source header
234-
final var sourceBlobName = exchange.getRequestHeaders().get("X-amz-copy-source");
235-
if (sourceBlobName != null) {
236-
var sourceBlob = blobs.get(sourceBlobName.getFirst());
234+
final var copySources = exchange.getRequestHeaders().get("X-amz-copy-source");
235+
if (copySources != null) {
236+
final var copySource = copySources.getFirst();
237+
final var prefix = copySource.length() > 0 && copySource.charAt(0) == '/' ? "" : "/";
238+
var sourceBlob = blobs.get(prefix + copySource);
237239
if (sourceBlob == null) {
238240
exchange.sendResponseHeaders(RestStatus.NOT_FOUND.getStatus(), -1);
239241
} else {

0 commit comments

Comments
 (0)