|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
688 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 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) {
|
|---|
| 17 | // Hex: 78
|
|---|
| 18 | const header = Buffer.alloc(2);
|
|---|
| 19 | header[0] = 120; // Hex: 78
|
|---|
| 20 | header[1] = 156; // Hex: 9C
|
|---|
| 21 | this.push(header, encoding);
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | this.__transform(chunk, encoding, callback);
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | export default ZlibHeaderTransformStream;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.