-
Notifications
You must be signed in to change notification settings - Fork 615
HDDS-15600. Fix ListObjects response for encoding-type, empty delimiter, and control-character prefix #10586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
cf2f8b2
45fdef1
1f720b5
2852242
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,11 +106,13 @@ public Response get( | |
| @Override | ||
| Response handleGetRequest(S3RequestContext context, String bucketName) throws IOException, OS3Exception { | ||
| final String continueToken = queryParams().get(QueryParams.CONTINUATION_TOKEN); | ||
| final String delimiter = queryParams().get(QueryParams.DELIMITER); | ||
| final String delimiter = queryParams().containsKey(QueryParams.DELIMITER) ? | ||
| queryParams().get(QueryParams.DELIMITER) : null; | ||
| final String encodingType = queryParams().get(QueryParams.ENCODING_TYPE); | ||
| final String marker = queryParams().get(QueryParams.MARKER); | ||
| int maxKeys = queryParams().getInt(QueryParams.MAX_KEYS, 1000); | ||
| String prefix = queryParams().get(QueryParams.PREFIX, ""); | ||
| final boolean prefixSpecified = queryParams().containsKey(QueryParams.PREFIX); | ||
| final String prefix = prefixSpecified ? queryParams().get(QueryParams.PREFIX) : ""; | ||
| String startAfter = queryParams().get(QueryParams.START_AFTER); | ||
|
|
||
| Iterator<? extends OzoneKey> ozoneKeyIterator = null; | ||
|
|
@@ -157,17 +159,21 @@ Response handleGetRequest(S3RequestContext context, String bucketName) throws IO | |
| if (encodingType != null && !encodingType.equals(ENCODING_TYPE)) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.INVALID_ARGUMENT, encodingType); | ||
| } | ||
|
|
||
| // If you specify the encoding-type request parameter,should return | ||
| // encoded key name values in the following response elements: | ||
| // Delimiter, Prefix, Key, and StartAfter. | ||
| // encoded key name values in the following response elements: Delimiter, | ||
| // Key, and StartAfter. The echoed Prefix request parameter is returned without URL encoding. | ||
| // | ||
| // For detail refer: | ||
| // https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#AmazonS3-ListObjectsV2-response-EncodingType | ||
| ListObjectResponse response = new ListObjectResponse(); | ||
| response.setDelimiter(EncodingTypeObject.createNullable(delimiter, encodingType)); | ||
| // AWS omits Delimiter from the response when the client passes delimiter= or does not specify delimiter at all. | ||
| if (delimiter != null && !delimiter.isEmpty()) { | ||
|
Gargi-jais11 marked this conversation as resolved.
Outdated
|
||
| response.setDelimiter(EncodingTypeObject.createNullable(delimiter, encodingType)); | ||
| } | ||
| response.setName(bucketName); | ||
| response.setPrefix(EncodingTypeObject.createNullable(prefix, encodingType)); | ||
| if (prefixSpecified) { | ||
| response.setPrefix(EncodingTypeObject.createNullable(prefix, null)); | ||
| } | ||
|
Comment on lines
+174
to
+176
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
AWS docs say Local test: aws s3api list-objects \
--bucket buck1 \
--prefix $'\n' \
--encoding-type url \
--endpoint-url http://localhost:9878/Actual: "Prefix": "\n"Expected: "Prefix": "%0A"Looks like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Russole thanks for bringing this in view. Will revert the changes for this but now the problem is With original : Local test: Actual is: Expected :
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder how to fix this part when encoding-type is not mentioned in the request. |
||
| response.setMarker(marker == null ? "" : marker); | ||
| response.setMaxKeys(maxKeys); | ||
| response.setEncodingType(encodingType); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.