/usr/local/lib/node_modules/pm2/node_modules/needle/test
NameSizeModeActions
utils/-0755rm
basic_auth_spec.js61390644editdlrm
compression_spec.js30270644editdlrm
cookies_spec.js101400644editdlrm
decoder_spec.js22300644editdlrm
errors_spec.js62950644editdlrm
headers_spec.js58100644editdlrm
helpers.js15380644editdlrm
long_string_spec.js6410644editdlrm
output_spec.js72920644editdlrm
parsing_spec.js135640644editdlrm
post_data_spec.js331190644editdlrm
proxy_spec.js49740644editdlrm
querystring_spec.js23290644editdlrm
redirect_spec.js110010644editdlrm
redirect_with_timeout.js13530644editdlrm
request_stream_spec.js53440644editdlrm
response_stream_spec.js37120644editdlrm
socket_pool_spec.js17620644editdlrm
url_spec.js28370644editdlrm
Edit: /usr/local/lib/node_modules/pm2/node_modules/needle/test/compression_spec.js (3027B)
var should = require('should'), needle = require('./../'), http = require('http'), zlib = require('zlib'), stream = require('stream'), port = 11123, server; describe('compression', function(){ require.bind(null, 'zlib').should.not.throw() var jsonData = '{"foo":"bar"}'; describe('when server supports compression', function(){ before(function(){ server = http.createServer(function(req, res) { var raw = new stream.PassThrough(); var acceptEncoding = req.headers['accept-encoding']; if (!acceptEncoding) { acceptEncoding = ''; } if (acceptEncoding.match(/\bdeflate\b/)) { res.setHeader('Content-Encoding', 'deflate'); raw.pipe(zlib.createDeflate()).pipe(res); } else if (acceptEncoding.match(/\bgzip\b/)) { res.setHeader('Content-Encoding', 'gzip'); raw.pipe(zlib.createGzip()).pipe(res); } else { raw.pipe(res); } res.setHeader('Content-Type', 'application/json') if (req.headers['with-bad']) { res.end('foo'); // end, no deflate data } else { raw.end(jsonData) } }) server.listen(port); }); after(function(done){ server.close(done); }) describe('and client requests no compression', function() { it('should have the body decompressed', function(done){ needle.get('localhost:' + port, function(err, response, body){ should.ifError(err); body.should.have.property('foo', 'bar'); response.bytes.should.equal(jsonData.length); done(); }) }) }) describe('and client requests gzip compression', function() { it('should have the body decompressed', function(done){ needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'gzip'}}, function(err, response, body){ should.ifError(err); body.should.have.property('foo', 'bar'); response.bytes.should.not.equal(jsonData.length); done(); }) }) }) describe('and client requests deflate compression', function() { it('should have the body decompressed', function(done){ needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'deflate'}}, function(err, response, body){ should.ifError(err); body.should.have.property('foo', 'bar'); response.bytes.should.not.equal(jsonData.length); done(); }) }) it('should rethrow errors from decompressors', function(done){ needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'deflate', 'With-Bad': 'true'}}, function(err, response, body) { should.exist(err); err.message.should.equal("incorrect header check"); err.code.should.equal("Z_DATA_ERROR") done(); }) }) }) }) })