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

Add gzip and deflate decoder for json content type #683

Merged
merged 2 commits into from
Nov 7, 2016

Conversation

dszakallas
Copy link
Contributor

@dszakallas dszakallas commented Sep 13, 2016

This pull request adds corresponding decoders when content encoding is 'gzip'or'deflate'`, but only if the content type is JSON.

Motivation:
currently, nock tries to parse JSON from the requestBody even if it is compressed and ultimately fails with a SyntaxError:

SyntaxError: Unexpected token f in JSON at position 1
    at Object.parse (native)
    at RequestOverrider.end (/omitted/node_modules/nock/lib/request_overrider.js:298:28)

This pull request solves this issue and in the request handler you get a decoded/parsed JSON. Behaviour for other content types should be unaffected.
As it uses sync API, it only works above node >=0.12

@vrinek
Copy link
Contributor

vrinek commented Oct 9, 2016

Hello and sorry for the lack of response. Please rebase on top of (or merge in) latest master as the tests are (finally) green again.

@dszakallas dszakallas force-pushed the feat/gzip-content-type-decoder branch from 77979b5 to b3d4081 Compare October 30, 2016 08:54
@coveralls
Copy link

coveralls commented Oct 30, 2016

Coverage Status

Coverage decreased (-0.05%) to 96.531% when pulling b3d4081 on szdavid92:feat/gzip-content-type-decoder into 192f0f8 on node-nock:master.

@dszakallas
Copy link
Contributor Author

Done!

@vrinek vrinek merged commit 2e56026 into nock:master Nov 7, 2016
@vrinek
Copy link
Contributor

vrinek commented Nov 7, 2016

Thanks for the contribution 😃

@lock
Copy link

lock bot commented Sep 13, 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 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants