main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
681 bytes
|
Rev | Line | |
---|
[d565449] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | import stream from "stream";
|
---|
| 4 |
|
---|
| 5 | class ZlibHeaderTransformStream extends stream.Transform {
|
---|
| 6 | __transform(chunk, encoding, callback) {
|
---|
| 7 | this.push(chunk);
|
---|
| 8 | callback();
|
---|
| 9 | }
|
---|
| 10 |
|
---|
| 11 | _transform(chunk, encoding, callback) {
|
---|
| 12 | if (chunk.length !== 0) {
|
---|
| 13 | this._transform = this.__transform;
|
---|
| 14 |
|
---|
| 15 | // Add Default Compression headers if no zlib headers are present
|
---|
| 16 | if (chunk[0] !== 120) { // Hex: 78
|
---|
| 17 | const header = Buffer.alloc(2);
|
---|
| 18 | header[0] = 120; // Hex: 78
|
---|
| 19 | header[1] = 156; // Hex: 9C
|
---|
| 20 | this.push(header, encoding);
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | this.__transform(chunk, encoding, callback);
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | export default ZlibHeaderTransformStream;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.