Skip to content

Commit

Permalink
Fix the issue of S3 range read
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

fix the issue of S3 range read. 

### Why are the changes needed?

there is a bug when setting  S3 range offset.

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

user can try the following cmd to validate S3 range read.
`aws --endpoint http://localhost:39999/api/v1/s3 s3api get-object --range bytes=10-20 --bucket [bucket-name] --key=[key-name] [output-file]`



			pr-link: #18484
			change-id: cid-b5fd9832a9900fba1105bb494a96f315b20f507d
  • Loading branch information
007DXR authored Jan 19, 2024
1 parent 4f07b99 commit 6f2a527
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public HttpResponse continueTask() {
response.headers()
.set(HttpHeaderNames.LAST_MODIFIED, new Date(status.getLastModificationTimeMs()));
response.headers().set(S3Constants.S3_CONTENT_LENGTH_HEADER,
status.isFolder() ? 0 : status.getLength());
status.isFolder() ? 0 : s3Range.getLength(status.getLength()));

// Check range
if (s3Range.isValid()) {
Expand Down Expand Up @@ -300,7 +300,7 @@ public void processGetObject(String ufsFullPath, S3RangeSpec range, long objectS
DataBuffer packet = null;
long offset = range.getOffset(objectSize);
long length = range.getLength(objectSize);
BlockReader blockReader = mHandler.openBlock(ufsFullPath, offset, length);
BlockReader blockReader = mHandler.openBlock(ufsFullPath, offset, offset + length);

// Writes http response to the netty channel before data.
mHandler.processHttpResponse(response, false);
Expand Down

0 comments on commit 6f2a527

Please sign in to comment.