Skip to content

Commit

Permalink
HDDS-10521. ETag field should not be returned during GetObject if the…
Browse files Browse the repository at this point in the history
… key does not contain ETag field (apache#6377)
  • Loading branch information
ivandika3 authored Mar 15, 2024
1 parent 2ffdb3c commit 3d193fc
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit 3d193fc

Please sign in to comment.