Skip to content

Commit

Permalink
Add baseRequestParams to AWSClient
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oleiade committed Jul 30, 2024
1 parent 8d9ef68 commit 54702b9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/internal/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RefinedResponse, ResponseType } from 'k6/http'
import { RefinedResponse, ResponseType, Params } from 'k6/http'

import { AWSConfig } from './config'
import { Endpoint } from './endpoint'
Expand Down Expand Up @@ -27,6 +27,22 @@ export class AWSClient {
readonly awsConfig: AWSConfig
readonly serviceName: string

// Because jslib-aws is mostly used as a way to setup or feed k6 tests, and
// we want the jslib-aws to be able to disregard k6's discardResponseBodies: meaning
// that for instance, even when setting discardResponseBodies to true in the k6 options, using
// s3.getObject still receives the underlying response body and returns data to the user.
//
// To achieve this, we set the responseType to 'text' in the baseRequestParams, as it
// will lead the http module to ignore the discardResponseBodies option.
//
// AWS Client classes can override this value if they want to receive the response body
// as a different type ('binary' for instance, e.g. S3Client.getObject).
//
// See #45: import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js'
readonly baseRequestParams: Params = {
responseType: 'text',
}

private _endpoint?: Endpoint

/**
Expand Down

0 comments on commit 54702b9

Please sign in to comment.