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

Disregard K6_DISCARD_RESPONSE_BODIES #114

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Jul 30, 2024

What

This Pull Request addresses #45, namely ignoring k6's discardResponseBodies and always returning response bodies obtained from jslib-aws HTTP calls.

How

In this PR, we introduce a baseRequestParams member in the AWSClient class, which we add to every request made by children class implementations.

Using the baseRequestParams we set the default responseType for children implementation, allowing us to effectively disregard the http discardResponseBodies option. We can still, locally, override it where necessary, as in S3Client.getObject, for instance.

Demo

The following script:

//... 

export default async function () {
    // List the buckets the AWS authentication configuration
    // gives us access to.
    const buckets = await s3.listBuckets()

    console.log(JSON.stringify(buckets))

    const responseWithBody = http.get('https://httpbin.org/get')
    console.log(responseWithBody.body)
}

Will display something along the lines of:

[INFO] {"some": "content"}
[INFO] []

References

closes #45

This allow us to ignore k6's discardResponseBodies in the context of
jslib-aws. As it is mostly a utility library, users have been mostly
about having the ability available. See #45 for details.

Using the baseRequestParams we set the default responseType for children
implementation, allowing us to effectively disregard the
http discardResponseBodies option. We can still, locally override it
where necessary, as in S3Client.getObject for instance.
@oleiade oleiade requested a review from a team as a code owner July 30, 2024 14:05
@oleiade oleiade requested review from codebien and joanlopez and removed request for a team July 30, 2024 14:05
@oleiade oleiade self-assigned this Jul 30, 2024
@oleiade oleiade added the enhancement New feature or request label Jul 30, 2024
@oleiade oleiade changed the title Add baseRequestParams to AWSClient Disregard K6_DISCARD_RESPONSE_BODIES Jul 30, 2024
src/internal/client.ts Outdated Show resolved Hide resolved
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
@oleiade oleiade merged commit fbe41eb into main Sep 6, 2024
2 of 3 checks passed
@oleiade oleiade deleted the fix_45_disregard_discard_response_bodies branch September 6, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

S3Client returns null when K6_DISCARD_RESPONSE_BODIES is set to true
3 participants