Fix Hurst fetch URL to use full API_BASE_URL and ensure endpoint returns JSON for all query params
This commit is contained in:
40
node_modules/union/examples/simple/middleware/gzip-encode.js
generated
vendored
Normal file
40
node_modules/union/examples/simple/middleware/gzip-encode.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
var spawn = require('child_process').spawn,
|
||||
util = require('util'),
|
||||
ResponseStream = require('../../lib').ResponseStream;
|
||||
|
||||
/**
|
||||
* Accepts a writable stream, i.e. fs.WriteStream, and returns a StreamStack
|
||||
* whose 'write()' calls are transparently sent to a 'gzip' process before
|
||||
* being written to the target stream.
|
||||
*/
|
||||
var GzipEncode = module.exports = function GzipEncode(options) {
|
||||
ResponseStream.call(this, options);
|
||||
|
||||
if (compression) {
|
||||
process.assert(compression >= 1 && compression <= 9);
|
||||
this.compression = compression;
|
||||
}
|
||||
|
||||
this.on('pipe', this.encode);
|
||||
}
|
||||
|
||||
util.inherits(GzipEncode, ResponseStream);
|
||||
|
||||
GzipEncode.prototype.encode = function (source) {
|
||||
this.source = source;
|
||||
};
|
||||
|
||||
GzipEncode.prototype.pipe = function (dest) {
|
||||
if (!this.source) {
|
||||
throw new Error('GzipEncode is only pipeable once it has been piped to');
|
||||
}
|
||||
|
||||
this.encoder = spawn('gzip', ['-'+this.compression]);
|
||||
this.encoder.stdout.pipe(dest);
|
||||
this.encoder.stdin.pipe(this.source);
|
||||
};
|
||||
|
||||
inherits(GzipEncoderStack, StreamStack);
|
||||
exports.GzipEncoderStack = GzipEncoderStack;
|
||||
|
||||
GzipEncoderStack.prototype.compression = 6;
|
||||
Reference in New Issue
Block a user