pollyjs
pollyjs copied to clipboard
Feature Request: Allow Recordings to be Saved Decoded and Unzipped
Description
Per the comment made here: https://github.com/Netflix/pollyjs/issues/265#issuecomment-544213400, it was suggested that adding the ability to allow recordings to be saved decoded and unzipped could be added to Pollyjs. We have open sourced various client libraries across 7 languages, each with its own "VCR" solution like Polly, each allowing for the recordings to be unzipped and decoded for manual inspection which is important to us. At present, we'd have to setup a lot of boilerplate code via beforePersist
to get Polly to decode/unzip all requests/responses when this is an ideal first class feature of Polly itself so that engineers can ensure the responses look like what we expect in a human readable fashion like we can using other language VCR solutions.
For our purposes, we needed to ensure it takes chunked responses into account as well and concatenated each chunk, decompressed them, then turned them into storable strings for the recording file itself. We then reversed the process for beforeReplay
.
I just discovered @Justintime50 that if you disable compression in your headers you can get it to work
https://github.com/Netflix/pollyjs/blob/06499fc2d85254b3329db2bec770d173ed32bca0/packages/%40pollyjs/adapter-node-http/src/index.js#L280
https://stackoverflow.com/questions/18398022/disable-gzip-compression-in-chrome
we shouldn't have to do that but its a temporary workaround
@Josiassejod1 although that works, it's not ideal for our situation.
The code we are using to accomplish this can be found here: https://github.com/EasyPost/easypost-node/pull/253/files#diff-34ee99ca00f431605c35bbb1974fb5cad2c5cd3c076ff29165d24d490c619459 (the PR is large but the file you want is the cassette_encoding.js
file. This link should take you there but may take a second to load due to the PR size)
I feel you on that @Justintime50 would rather this be an option that can be toggled
I think this would be useful as well. For comparison the vcr gem in the Ruby world does this.
The reason is that it allows us to easily see what is really being requested and responded.