Skip to content
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

HDDS-10521. ETag field should not be returned during GetObject if the key does not contain ETag field #6377

Merged
merged 1 commit into from
Mar 15, 2024
Merged
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 @@ -483,9 +483,12 @@ public Response get(
responseBuilder.header(CONTENT_RANGE_HEADER, contentRangeVal);
}
responseBuilder
.header(ETAG, wrapInQuotes(keyDetails.getMetadata().get(ETAG)))
.header(ACCEPT_RANGE_HEADER, RANGE_HEADER_SUPPORTED_UNIT);

if (keyDetails.getMetadata().get(ETAG) != null) {
responseBuilder.header(ETAG, wrapInQuotes(keyDetails.getMetadata().get(ETAG)));
}

// if multiple query parameters having same name,
// Only the first parameters will be recognized
// eg:
Expand Down Expand Up @@ -591,9 +594,16 @@ public Response head(
}

ResponseBuilder response = Response.ok().status(HttpStatus.SC_OK)
.header(ETAG, "" + wrapInQuotes(key.getMetadata().get(ETAG)))
.header("Content-Length", key.getDataSize())
.header("Content-Type", "binary/octet-stream");

if (key.getMetadata().get(ETAG) != null) {
// Should not return ETag header if the ETag is not set
// doing so will result in "null" string being returned instead
// which breaks some AWS SDK implementation
response.header(ETAG, "" + wrapInQuotes(key.getMetadata().get(ETAG)));
}

addLastModifiedDate(response, key);
addCustomMetadataHeaders(response, key);
getMetrics().updateHeadKeySuccessStats(startNanos);
Expand Down
Loading