-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Backport fix for zlib inflation with custom dicts to 4.x #9358
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| 'use strict'; | ||
| // test compression/decompression with dictionary | ||
|
|
||
| require('../common'); | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const zlib = require('zlib'); | ||
|
|
||
|
|
@@ -69,6 +69,66 @@ function run(num) { | |
| } | ||
| run(1); | ||
|
|
||
| function rawDictionaryTest() { | ||
| let output = ''; | ||
| const deflate = zlib.createDeflateRaw({ dictionary: spdyDict }); | ||
| const inflate = zlib.createInflateRaw({ dictionary: spdyDict }); | ||
|
|
||
| deflate.on('data', function(chunk) { | ||
| inflate.write(chunk); | ||
| }); | ||
|
|
||
| inflate.on('data', function(chunk) { | ||
| output += chunk; | ||
| }); | ||
|
|
||
| deflate.on('end', function() { | ||
| inflate.end(); | ||
| }); | ||
|
|
||
| inflate.on('end', common.mustCall(function() { | ||
| assert.equal(input, output); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So just to be clear, do you want me to backport both of the commits from last time, both the actual fix and the test fixes? I thought you said just to backport the first, that's why I didn't include the test refactors, but I might have misunderstood. I'd be happy to do them both if that's what you want.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thusoy That’s basically your call, and you don’t need to fix these. I would expect backporting the second commit to be more prone to merge conflicts and just generally a bit more work, but of course it’s appreciated if that’s something you’d like to do (partially or wholly). I was just commenting here because the diff looks different from the one in #8512, that’s all.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seeing how different the tests are here I imagine backporting the other one would be quite painful, yes, I don't think I'm masochistic enough for that. I can address the points you raise if you like, but they were not part of the original first commit either, so I skipped them to keep the same style as the surrounding code.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. :) I’m fine then as long as the tests are passing. (edit: I’d kick off CI if it wasn’t timing out again…)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, at your leisure then. (For the record, it Works On My Machine (tm)). |
||
| })); | ||
|
|
||
| deflate.write(input); | ||
| deflate.end(); | ||
| } | ||
|
|
||
| function deflateRawResetDictionaryTest() { | ||
| let doneReset = false; | ||
| let output = ''; | ||
| const deflate = zlib.createDeflateRaw({ dictionary: spdyDict }); | ||
| const inflate = zlib.createInflateRaw({ dictionary: spdyDict }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (ditto for |
||
|
|
||
| deflate.on('data', function(chunk) { | ||
| if (doneReset) | ||
| inflate.write(chunk); | ||
| }); | ||
|
|
||
| inflate.on('data', function(chunk) { | ||
| output += chunk; | ||
| }); | ||
|
|
||
| deflate.on('end', function() { | ||
| inflate.end(); | ||
| }); | ||
|
|
||
| inflate.on('end', common.mustCall(function() { | ||
| assert.equal(input, output); | ||
| })); | ||
|
|
||
| deflate.write(input); | ||
| deflate.flush(function() { | ||
| deflate.reset(); | ||
| doneReset = true; | ||
| deflate.write(input); | ||
| deflate.end(); | ||
| }); | ||
| } | ||
|
|
||
| rawDictionaryTest(); | ||
| deflateRawResetDictionaryTest(); | ||
|
|
||
| process.on('exit', function() { | ||
| assert.equal(called, 2); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
inflate.setEncoding('utf-8');call seems to be missing?