rich7420 opened a new pull request, #11612: URL: https://github.com/apache/ozone/pull/11612
## What changes were proposed in this pull request? This PR supersedes #9540, which was auto-closed by the stale bot and could not be reopened. The change is reimplemented on the current `master`, since `ObjectEndpoint.head()` and `TestObjectHead` have changed significantly since then (partNumber, conditional requests, bucket owner checks). S3 Gateway HeadObject ignores the `Range` header and always returns 200 with the full object size, while AWS S3 returns the metadata of the requested range. With this change, HeadObject handles `Range` the same way as GetObject: - a satisfiable range returns `206 Partial Content`, with `Content-Length` of the range and `Content-Range: bytes start-end/size` - an unsatisfiable range returns `416` (`InvalidRange`) - `Accept-Ranges: bytes` is returned on all successful responses - preconditions (`If-Match`, `If-None-Match`, etc.) are evaluated before the range, as in GetObject Range parsing reuses `RangeHeaderParserUtil`, so HEAD and GET behave identically for every range value. Out of scope: rejecting `partNumber` combined with `Range` (AWS returns 400). GetObject does not handle this either, so it should be fixed for both in a separate Jira. Review comments from #9540 are addressed as follows: - range parsing moved into the block where headers are parsed, replacing the TODO - tests reuse `keyEndpoint` and `headers` from `setup()`, so there is no new endpoint, client field, or cleanup method - key name and content are constants; range cases are a single `@ParameterizedTest` - header names use `HttpHeaders` / `S3Consts` constants - the invalid range case uses `assertErrorResponse(INVALID_RANGE, ...)` ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-14224 ## How was this patch tested? - Added unit tests in `TestObjectHead` (no range, bounded, open-ended, suffix, clipped end, inverted, invalid range, and precondition precedence over range). The new range tests fail without the production change (7 failures) and pass with it. - Added `testHeadObjectRange` to `AbstractS3SDKV2Tests` (AWS SDK V1 `getObjectMetadata` cannot send `Range`, so there is no V1 test). - `mvn -pl :ozone-s3gateway test -Dtest=TestObjectHead,TestObjectGet`: 47 run, 0 failed - `mvn -pl :ozone-integration-test-s3 test -Dtest=TestS3SDK`: 234 run, 0 failed - `checkstyle.sh` and `pmd:check` clean -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
