Function
unchunk
(encoding, onchunk, onend)
Source from the content-addressed store, hash-verified
| 1055 | } |
| 1056 | |
| 1057 | function unchunk (encoding, onchunk, onend) { |
| 1058 | return function (res) { |
| 1059 | var stream |
| 1060 | |
| 1061 | assert.strictEqual(res.headers['content-encoding'], encoding) |
| 1062 | |
| 1063 | switch (encoding) { |
| 1064 | case 'deflate': |
| 1065 | stream = res.pipe(zlib.createInflate()) |
| 1066 | break |
| 1067 | case 'gzip': |
| 1068 | stream = res.pipe(zlib.createGunzip()) |
| 1069 | break |
| 1070 | case 'br': |
| 1071 | stream = res.pipe(zlib.createBrotliDecompress()) |
| 1072 | break |
| 1073 | } |
| 1074 | |
| 1075 | stream.on('data', onchunk) |
| 1076 | stream.on('end', onend) |
| 1077 | } |
| 1078 | } |
Tested by
no test coverage detected