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

Running Stat on GetObject before reading discards range #1813

Open
klauspost opened this issue Apr 28, 2023 · 0 comments
Open

Running Stat on GetObject before reading discards range #1813

klauspost opened this issue Apr 28, 2023 · 0 comments
Assignees

Comments

@klauspost
Copy link
Contributor

klauspost commented Apr 28, 2023

Running the code:

		gopts := minio.GetObjectOptions{}
		err = gopts.SetRange(100, 1000)
		if err != nil {
			panic(err)
		}
		fmt.Println("HDR:", gopts.Header())
		c.TraceOn(os.Stdout)
		r, err := c.GetObject(context.Background(), bucketName, objectName, gopts)
		if err != nil {
			panic(err)
		}
		
		if false { // enable to get correct size
			_, err := io.ReadAll(r)
			if err != nil {
				panic(err)
			}
		}
		
		st, err := r.Stat()
		if err != nil {
			panic(err)
		}
		fmt.Println("Size:", st.Size)

This discards the range and the reported size is the full object. Enabling the read gives the expected size (901 bytes).

Without reading:

HEAD /minio-go-test-viijedtgbwiqglb3/ugmagqw0xesk0cckvwprlghclgj4fp HTTP/1.1
Host: 127.0.0.1:9001
User-Agent: MinIO (windows; amd64) minio-go/v7.0.53 MinIO-go-FunctionalTest/0.1.0
Authorization: AWS4-HMAC-SHA256 Credential=minio/20230428/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-checksum-mode;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20230428T082415Z

When reading:

GET /minio-go-test-6sekkdglutgfh2b3/406ojw4qjhtfhz04bzktyeof153e3b HTTP/1.1
Host: 127.0.0.1:9001
User-Agent: MinIO (windows; amd64) minio-go/v7.0.53 MinIO-go-FunctionalTest/0.1.0
Authorization: AWS4-HMAC-SHA256 Credential=minio/20230428/us-east-1/s3/aws4_request, SignedHeaders=host;range;x-amz-checksum-mode;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**
Range: bytes=100-1000
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20230428T082515Z

Doing the read after the Stat still discards the Range:

GET /minio-go-test-nku3o02lbjak9g00/pk0a9aomse5lwbm4oaxzsicki5pt1q HTTP/1.1
Host: 127.0.0.1:9001
User-Agent: MinIO (windows; amd64) minio-go/v7.0.53 MinIO-go-FunctionalTest/0.1.0
Authorization: AWS4-HMAC-SHA256 Credential=minio/20230428/us-east-1/s3/aws4_request, SignedHeaders=host;if-match;x-amz-checksum-mode;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**
If-Match: "f7234306c5f424246875f826ceae3e19"
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20230428T082858Z

... and the full object is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants