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

Nock back is recording response as binary array #457

Closed
wprater opened this Issue Jan 24, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@wprater
Contributor

wprater commented Jan 24, 2016

For a handful of my nocks, Im getting an array as the response being recorded when only json was sent from the server. It's an array of two entries of what seems to be binary data.

Im using supertest and nock.back.

thoughts?

@wprater

This comment has been minimized.

Contributor

wprater commented Jan 24, 2016

compression was on for the express app, turned this off in the test ENV and it was fixed. does not explain why only sometimes the response was not being decoded tho. the header transfer-encoding': 'chunked'. will close this issue, unless you think there is a bug in nock, feel free to re-open.

@wprater wprater closed this Jan 24, 2016

@wprater

This comment has been minimized.

Contributor

wprater commented Jan 24, 2016

maybe this was a regression of #444 ?

@richardscarrott

This comment has been minimized.

richardscarrott commented Sep 7, 2018

@wprater digging up an old one here but I'm experiencing the same issue with APIs which return 'Content-Encoding': 'gzip' and 'Transfer-Encoding': 'chunked' -- I'm having to post process it like this which doesn't feel correct:

const { ungzip } = require('node-gzip');

try {
  if (Array.isArray(def.response)) {
    def.response = JSON.parse(
      (await ungzip(Buffer.from(def.response.join(''), 'hex'))).toString(
        'utf-8'
      )
    );
  }
} catch (ex) {
  console.warn('Failed to decode response');
}

cc @gr2m

@gr2m

This comment has been minimized.

Member

gr2m commented Sep 9, 2018

@richardscarrott can you create a new issue please and we take it from there?

@richardscarrott

This comment has been minimized.

richardscarrott commented Sep 9, 2018

@gr2m I've created an issue here #1212, thanks

@lock

This comment has been minimized.

lock bot commented Sep 23, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2018

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