Skip to content

Response body is not properly decompressed when gzip is true #998

Closed
@RandScullard

Description

@RandScullard

I ran into a problem where my capture was not working, and I debugged through Artillery and found that the problem was that it was trying to parse the compressed data. If I set gzip: false on my post, the captures work fine, but if I set gzip to true, they fail.

The problem seems to be in this block of code in HttpEngine.prototype._handleResponse:

  let body = '';
  if (maybeCallback) {
    res.on('data', (d) => {
      body += d;
    });
  }

When I put a breakpoint on the line body += d; with gzip set to true and a compressed HTTP response, I see that d contains a big block of compressed data. It looks like you may need to use a different technique with the got package to access the decompressed response body.

For now, my workaround is to set gzip to false. This way, the server does not send a compressed response so the problematic code path is avoided.

Activity

hassy

hassy commented on Apr 20, 2021

@hassy
Member

It looks like Got added a response.body property since the HTTP engine was originally upgraded from Request.js to Got, so we can probably get rid of that bit of code, and rely on Got to decompress gzipped responses before we run captures on them.

Thank you for looking into it @RandScullard!

hassy

hassy commented on Apr 21, 2021

@hassy
Member

Fixed in v1.7.2

wcaquino

wcaquino commented on Jul 13, 2022

@wcaquino

I had a similar issue using the artillery version 2.0.0-21. However, based on this thread, when I downgraded the Artillery version to 1.7.2, my script worked as expected. Has anything changed since then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hassy@wcaquino@RandScullard

        Issue actions

          Response body is not properly decompressed when gzip is true · Issue #998 · artilleryio/artillery