Skip to content

Commit

Permalink
Return 404 when head the file end with slash
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?
if the request ends with "/" and the object is a file, return 404

### Why are the changes needed?
if the user want to get the metadata of a file, it should not end with "/". if the user wants to get the metadata of a dir, then it should end with "/".

### Does this PR introduce any user facing changes?
no

			pr-link: #18602
			change-id: cid-beaeba5de7ceb9b7ed0d92ad2a171f3ef8523e9d
  • Loading branch information
Jackson-Wang-7 authored May 10, 2024
1 parent 4adc159 commit 30fc5fb
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ public Response getObjectMetadata(@PathParam("bucket") final String bucket,
URIStatus status = userFs.getStatus(objectUri);
if (status.isFolder() && !object.endsWith(AlluxioURI.SEPARATOR)) {
throw new FileDoesNotExistException(status.getPath() + " is a directory");
} else if (!status.isFolder() && object.endsWith(AlluxioURI.SEPARATOR)) {
throw new FileDoesNotExistException(status.getPath() + " is a file");
}
Response.ResponseBuilder res = Response.ok()
.lastModified(new Date(status.getLastModificationTimeMs()))
Expand Down

0 comments on commit 30fc5fb

Please sign in to comment.