[GH-ISSUE #239] Expected headers are not sent for ObjectHandle.NewReader() #2198

Closed
opened 2026-03-15 17:59:22 +03:00 by kerem · 3 comments
Owner

Originally created by @ericnorris on GitHub (May 8, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/239

The Reader you get from ObjectHandle.NewReader has an Attrs field of type ReaderObjectAttrs.

The storage library fills those values in based on headers sent in the response:

github.com/googleapis/google-cloud-go@bd00477b30/storage/reader.go (L255-L268)

As far as I can tell, fakestorage is not setting these headers, which means that you get something like the following when you try to use them:

reader attrs: {Size:56 StartOffset:0 ContentType: ContentEncoding: CacheControl: LastModified:0001-01-01 00:00:00 +0000 UTC Generation:-1 Metageneration:0}

This library has been great, but including these headers would make it so that I can safely use the Attrs attribute and be able to test. Thanks!

Originally created by @ericnorris on GitHub (May 8, 2020). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/239 The [Reader](https://godoc.org/cloud.google.com/go/storage#Reader) you get from `ObjectHandle.NewReader` has an `Attrs` field of type [ReaderObjectAttrs](https://godoc.org/cloud.google.com/go/storage#ReaderObjectAttrs). The `storage` library fills those values in based on headers sent in the response: https://github.com/googleapis/google-cloud-go/blob/bd00477b309def1610fbf4cb259329deac795891/storage/reader.go#L255-L268 As far as I can tell, `fakestorage` is not setting these headers, which means that you get something like the following when you try to use them: ``` reader attrs: {Size:56 StartOffset:0 ContentType: ContentEncoding: CacheControl: LastModified:0001-01-01 00:00:00 +0000 UTC Generation:-1 Metageneration:0} ``` This library has been great, but including these headers would make it so that I can safely use the `Attrs` attribute _and_ be able to test. Thanks!
kerem closed this issue 2026-03-15 17:59:28 +03:00
Author
Owner

@fsouza commented on GitHub (May 11, 2020):

Hi @ericnorris, thanks for reporting. Can you check if #240 fixes the issue for you?

Thanks!

<!-- gh-comment-id:626441054 --> @fsouza commented on GitHub (May 11, 2020): Hi @ericnorris, thanks for reporting. Can you check if #240 fixes the issue for you? Thanks!
Author
Owner

@someone1 commented on GitHub (May 11, 2020):

I just conditionally added Content-Encoding - I don't think metadata generation is supported so I couldn't add that.

<!-- gh-comment-id:626860666 --> @someone1 commented on GitHub (May 11, 2020): I just conditionally added `Content-Encoding` - I don't think metadata generation is supported so I couldn't add that.
Author
Owner

@ericnorris commented on GitHub (May 12, 2020):

Hey @fsouza, I just had a chance to test locally and it does seem to fix the issue. Thanks, and thanks @someone1 for the quick fix!

<!-- gh-comment-id:627439291 --> @ericnorris commented on GitHub (May 12, 2020): Hey @fsouza, I just had a chance to test locally and it does seem to fix the issue. Thanks, and thanks @someone1 for the quick fix!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#2198
No description provided.