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

Allow binary responses in getObject #107

Closed
wants to merge 6 commits into from

Conversation

KOConchobhair
Copy link
Contributor

Fixes #105

@KOConchobhair KOConchobhair marked this pull request as ready for review June 15, 2024 19:45
@KOConchobhair KOConchobhair requested a review from a team as a code owner June 15, 2024 19:45
@KOConchobhair KOConchobhair requested review from codebien and olegbespalov and removed request for a team June 15, 2024 19:45
@oleiade oleiade requested review from oleiade and joanlopez and removed request for codebien and olegbespalov June 17, 2024 13:04
@oleiade
Copy link
Member

oleiade commented Jun 17, 2024

Enforcing @joanlopez and me as reviewers as we've been following the source issue 👀

@oleiade
Copy link
Member

oleiade commented Jun 17, 2024

See design considerations in #105.

@oleiade
Copy link
Member

oleiade commented Jun 19, 2024

Hey @KOConchobhair 👋🏻

We have discussed it internally, and the maintainers agree we'd prefer the approach depicted in #105 (comment).

If you have the capacity, we'd greatly appreciate it if you could align this PR's design. Otherwise, that's also fine, and we'd likely proceed with it ourselves. Just let us know 🙇🏻

@KOConchobhair
Copy link
Contributor Author

KOConchobhair commented Jun 19, 2024

Sorry for the delay, I was a little confused by your suggestion in #105 (comment) since Accept is not even one of the headers listed at the S3 link. But i guess you are saying that it gives you the path to support them in the future.

I will just state that this is not an S3 API problem at all, its a very specific problem related to the inner workings of k6. So specifying an Accept header that doesn't actually change how S3 responds and only impacts the parsing on the k6 side is a little odd (but again, its putting in place the API for future stuff which is nice to not break the API again). I think this makes it a little difficult to support all types of binary headers (so we'll have to add images too, so i guess image/*)

but this is a blocker for me using k6 how I want to in my project so I'll implement since I'd really like to continue using k6
😄

@oleiade
Copy link
Member

oleiade commented Jun 19, 2024

We know this is not an official AWS header, but it is an official HTTP header, and it indicates to the server the response type you expect to receive back, so it is a good fit.

This is also why we call it additionalHeaders and not requestParameterHeaders: It allows you to add any headers to the request, not only AWS ones. Not being able to set the underlying HTTP request's headers has caused a couple of issues in this project over time. It is actually a design we could probably extend to the AWSClient itself to a certain extent (although I can't necessarily think on top of my head of another method that would have the same need to express its result, which should be treated as bytes).

This way of doing it feels like a better mitigation than aligning with the responseType approach of the k6 HTTP client, which is not ideal in my experience and, as we're redesigning our HTTP client, might go away in the future.

Regarding the different MIME types supported, my assumption was that using the Accept header in this case was meant more as a convention than a strict requirement we would expect S3 to comply with: " If you set the Accept header, the S3 client will return binary content, otherwise text."

I'll look at the official support AWS headers to see if another candidate I might have overlooked shows up 🙇🏻

@KOConchobhair
Copy link
Contributor Author

KOConchobhair commented Jun 19, 2024

Regarding the different MIME types supported, my assumption was that using the Accept header in this case was meant more as a convention than a strict requirement we would expect S3 to comply with: " If you set the Accept header, the S3 client will return binary content, otherwise text."

Just thinking from a k6 user perspective though, giving something as broad as an Accept header in this API which allows me to set it to { 'Accept': 'application/json' } and then that would mean k6 will interpret as binary, that would be surprising and non-intuitive behavior if I were writing a k6 script.

@oleiade
Copy link
Member

oleiade commented Jun 19, 2024

For clarification, as mentioned in my initial comment only "Accept: application/octet-stream" would lead to the content being treated as binary.

@KOConchobhair
Copy link
Contributor Author

oh duh, okay so rephrased "If you set the Accept header (to application/octect-stream), the S3 client will return binary content, otherwise text."

@oleiade
Copy link
Member

oleiade commented Jun 26, 2024

Hey @KOConchobhair 👋🏻

Will you have capacity to update the PR according to our discussions? 🙇🏻

PS: I will be away for the next two weeks, but @joanlopez will be able to follow-up on this in the meantime.

@KOConchobhair
Copy link
Contributor Author

this is still on my list but fell down the priority a bit, hopefully i can get back to it this week

@oleiade
Copy link
Member

oleiade commented Jul 31, 2024

Closing in favor of #113

@oleiade oleiade closed this Jul 31, 2024
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

Successfully merging this pull request may close these issues.

S3Client.getObject does not work for binary data
2 participants