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

Discard binary HTTP response bodies by default #845

Open
na-- opened this issue Nov 21, 2018 · 1 comment
Open

Discard binary HTTP response bodies by default #845

na-- opened this issue Nov 21, 2018 · 1 comment
Labels
enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API performance

Comments

@na--
Copy link
Member

na-- commented Nov 21, 2018

Unless users have explicitly specified that they want to keep the body of a particular http.batch() request (i.e. have set its responseType to binary or text) that returns a binary content-type, we probably should discard its response body. The actual body contents of things like images, videos and other binary files are very rarely actually needed, and discarding them would save a ton of memory when discardResponseBodies isn't turned on.

Some things to consider:

  • Non-batch() HTTP requests should probably also be treated the same way, both for consistency and to reduce the implementation complexity
  • We probably need to introduce a new property in the Response object for the response body's length, since we currently would loose it, and it may be a useful property for checks.
  • Whether we should use a whitelist or a blacklist for the content types we want to discard... I think by default we should keep the body, unless the content-type matches a very restrictive blacklist like ^image/.+|audio/.+|video/.+)$ (and maybe include some or all of the application/ MIME types)
  • That list should probably be user-configurable, at least via the exported options...
@na-- na-- added the evaluation needed proposal needs to be validated or tested before fully implementing it in k6 label Aug 27, 2019
@tom-miseur
Copy link

A check against the Content-Type response header is usually all one needs to determine success of a request resulting in binary content, although being able to also check the response length might be useful, but much less critical. I don't think I've ever seen a server respond with the expected Content-Type when it isn't actually the "thing" you're expecting; what tends to happen is you get an error page which is then Content-Type: text/html (or something else).
Given the memory improvements this would yield, I'd say it's worth implementing as a sensible default.

@na-- na-- added the new-http issues that would require (or benefit from) a new HTTP API label Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API performance
Projects
None yet
Development

No branches or pull requests

2 participants