Socket
Socket
Sign inDemoInstall

wreck

Package Overview
Dependencies
2
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.6.0 to 5.6.1

21

lib/index.js

@@ -80,2 +80,3 @@

url = internals.resolveUrl(options.baseUrl, url);
delete options.baseUrl;
}

@@ -180,8 +181,7 @@

var redirectOptions = {
headers: options.headers,
payload: shadow || options.payload, // shadow must be ready at this point if set
redirects: --redirects
};
var redirectOptions = Hoek.cloneWithShallow(options, ['agent', 'payload', 'downstreamRes']);
redirectOptions.payload = shadow || options.payload; // shadow must be ready at this point if set
redirectOptions.redirects = --redirects;
return self.request(redirectMethod, location, redirectOptions, finish, _trace);

@@ -197,2 +197,3 @@ };

}, options.timeout);
delete options.timeout;
}

@@ -258,3 +259,2 @@

// Set stream timeout

@@ -285,3 +285,5 @@

if (err || !options.json) {
if (err ||
!options.json) {
return callback(err, buffer);

@@ -338,3 +340,6 @@ }

res.destroy();
if (res.destroy) { // GZip stream has no destroy() method
res.destroy();
}
return finish(err);

@@ -341,0 +346,0 @@ };

{
"name": "wreck",
"description": "HTTP Client Utilities",
"version": "5.6.0",
"version": "5.6.1",
"repository": "git://github.com/hapijs/wreck",

@@ -6,0 +6,0 @@ "main": "lib/index",

@@ -15,2 +15,9 @@ // Load modules

// Declare internals
var internals = {
payload: new Array(1640).join('0123456789') // make sure we have a payload larger than 16384 bytes for chunking coverage
};
// Test shortcuts

@@ -24,4 +31,2 @@

var payload = new Array(1640).join('0123456789'); // make sure we have a payload larger than 16384 bytes for chunking coverage
describe('request()', function () {

@@ -34,3 +39,3 @@

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
});

@@ -46,3 +51,3 @@

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -66,3 +71,3 @@ done();

Wreck.request('post', 'http://localhost:' + server.address().port, { payload: payload }, function (err, res) {
Wreck.request('post', 'http://localhost:' + server.address().port, { payload: internals.payload }, function (err, res) {

@@ -73,3 +78,3 @@ expect(err).to.not.exist();

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -118,3 +123,3 @@ done();

Wreck.request('post', 'http://localhost:' + server.address().port, { headers: { 'user-agent': 'wreck' }, payload: payload }, function (err, res) {
Wreck.request('post', 'http://localhost:' + server.address().port, { headers: { 'user-agent': 'wreck' }, payload: internals.payload }, function (err, res) {

@@ -125,3 +130,3 @@ expect(err).to.not.exist();

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -144,3 +149,3 @@ done();

Wreck.request('post', 'http://localhost:' + server.address().port, { payload: Wreck.toReadableStream(payload) }, function (err, res) {
Wreck.request('post', 'http://localhost:' + server.address().port, { payload: Wreck.toReadableStream(internals.payload) }, function (err, res) {

@@ -151,3 +156,3 @@ expect(err).to.not.exist();

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -165,3 +170,3 @@ done();

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
server.close();

@@ -181,3 +186,3 @@ done();

Wreck.request('get', 'https://google.com', { rejectUnauthorized: true, agent: new Https.Agent() }, function (err, res) {});
Wreck.request('get', 'https://google.com', { rejectUnauthorized: true, agent: new Https.Agent() }, function (err, res) { });
};

@@ -193,3 +198,3 @@

Wreck.request('get', 'https://google.com', { rejectUnauthorized: false, agent: false }, function (err, res) {});
Wreck.request('get', 'https://google.com', { rejectUnauthorized: false, agent: false }, function (err, res) { });
};

@@ -205,3 +210,3 @@

Wreck.request('get', 'https://google.com', { rejectUnauthorized: false, agent: null }, function (err, res) {});
Wreck.request('get', 'https://google.com', { rejectUnauthorized: false, agent: null }, function (err, res) { });
};

@@ -291,2 +296,36 @@

it('applies rejectUnauthorized when redirected', function (done) {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YBNdCwyN1RVfCEen5wEU/gBfAluRzATxrf7H0FuFuKbrwR5AcV\nkltRL23nIDRCEvYUxrx15Bc5uMSdnvQx6dsaFQI0RAu9weyWxYXOWRhnISsPghZg\nIjcrFNA5gYEHGnNHoNqVqE/mBpk3kI+rEVzuu59scv4QNQ7jegOFgSt8DNzuAZ0x\ntHTW1lBG3u8gG1eYBMquexoSSHmMUb73lQ2l/dC6AKjOHFB9Ouq3IjjdFGwx1diz\n/yWh+Y8wY1Mgpyiy6ObJ5W8CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAoSc6Skb4\ng1e0ZqPKXBV2qbx7hlqIyYpubCl1rDiEdVzqYYZEwmst36fJRRrVaFuAM/1DYAmT\nWMhU+yTfA+vCS4tql9b9zUhPw/IDHpBDWyR01spoZFBF/hE1MGNpCSXXsAbmCiVf\naxrIgR2DNketbDxkQx671KwF1+1JOMo9ffXp+OhuRo5NaGIxhTsZ+f/MA4y084Aj\nDI39av50sTRTWWShlN+J7PtdQVA5SZD97oYbeUeL7gI18kAJww9eUdmT0nEjcwKs\nxsQT1fyKbo7AlZBY4KSlUMuGnn0VnAsB9b+LxtXlDfnjyM8bVQx1uAfRo0DO8p/5\n3J5DTjAU55deBQ==\n-----END CERTIFICATE-----\n'
};
var gen = 0;
var server = Https.createServer(httpsOptions, function (req, res) {
if (!gen++) {
res.writeHead(301, { 'Location': '/' });
res.end();
}
else {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end();
}
});
server.listen(0, function (err) {
expect(err).to.not.exist();
Wreck.request('get', 'https://localhost:' + server.address().port, { redirects: 1, rejectUnauthorized: false }, function (err, res) {
expect(err).to.not.exist();
expect(res.statusCode).to.equal(200);
server.close();
done();
});
});
});
it('requests a resource with downstream dependency', function (done) {

@@ -297,3 +336,3 @@

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
});

@@ -321,3 +360,3 @@

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
up.close();

@@ -343,3 +382,3 @@ down.close();

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
}

@@ -375,3 +414,3 @@ });

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
}

@@ -388,3 +427,3 @@ });

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -407,4 +446,5 @@ done();

else {
expect(req.url).to.equal('/');
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
}

@@ -421,3 +461,3 @@ });

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -441,3 +481,3 @@ done();

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(payload);
res.end(internals.payload);
}

@@ -496,3 +536,3 @@ });

Wreck.request('post', 'http://localhost:' + server.address().port, { redirects: 1, payload: Wreck.toReadableStream(payload) }, function (err, res) {
Wreck.request('post', 'http://localhost:' + server.address().port, { redirects: 1, payload: Wreck.toReadableStream(internals.payload) }, function (err, res) {

@@ -503,3 +543,3 @@ expect(err).to.not.exist();

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -730,2 +770,39 @@ done();

it('applies agent option when redirected', function (done) {
var gen = 0;
var server = Http.createServer(function (req, res) {
if (!gen++) {
res.writeHead(301, { 'Location': '/' });
res.end();
}
else {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end();
}
});
var agent = new Http.Agent();
var requestCount = 0;
var addRequest = agent.addRequest;
agent.addRequest = function () {
requestCount++;
addRequest.apply(agent, arguments);
};
server.listen(0, function () {
Wreck.request('get', 'http://localhost:' + server.address().port, { redirects: 1, agent: agent }, function (err, res) {
expect(err).to.not.exist();
expect(res.statusCode).to.equal(200);
expect(requestCount).to.equal(2);
server.close();
done();
});
});
});
it('pooling can be disabled by setting agent to false', function (done) {

@@ -789,3 +866,3 @@

var buf = new Buffer(payload, 'ascii');
var buf = new Buffer(internals.payload, 'ascii');

@@ -798,3 +875,3 @@ Wreck.request('post', 'http://localhost:' + server.address().port, { payload: buf }, function (err, res) {

expect(err).to.not.exist();
expect(body.toString()).to.equal(payload);
expect(body.toString()).to.equal(internals.payload);
server.close();

@@ -817,3 +894,3 @@ done();

var buf = new Buffer(payload, 'ascii');
var buf = new Buffer(internals.payload, 'ascii');

@@ -937,3 +1014,3 @@ Wreck.request('head', 'http://localhost:' + server.address().port, { payload: null }, function (err, res) {

res.writeHead(200);
res.write(payload);
res.write(internals.payload);
res.end();

@@ -1105,3 +1182,3 @@ });

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write(payload);
res.write(internals.payload);
});

@@ -1131,4 +1208,4 @@

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write(payload);
res.end(payload);
res.write(internals.payload);
res.end(internals.payload);
});

@@ -1251,3 +1328,3 @@

var res = Wreck.toReadableStream(payload);
var res = Wreck.toReadableStream(internals.payload);
Wreck.read(res, { json: true }, function (err) {

@@ -1259,2 +1336,30 @@

});
it('skips destroy when not available', function (done) {
var server = Http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write(internals.payload);
res.end(internals.payload);
});
server.listen(0, function () {
Wreck.request('get', 'http://localhost:' + server.address().port, {}, function (err, res) {
expect(err).to.not.exist();
res.destroy = null;
Wreck.read(res, { maxBytes: 120 }, function (err, body) {
expect(err).to.exist();
expect(err.output.statusCode).to.equal(400);
expect(body).to.not.exist();
server.close();
done();
});
});
});
});
});

@@ -1751,4 +1856,2 @@

var req;
var optionsA = { headers: { foo: 123 } };

@@ -1764,19 +1867,19 @@ var optionsB = { headers: { bar: 321 } };

req = wreckA.request('get', 'http://localhost/', { headers: { banana: 911 } }, function (err, res) {
var req1 = wreckA.request('get', 'http://localhost/', { headers: { banana: 911 } }, function (err) {
expect(req._headers.banana).to.exist();
expect(req._headers.foo).to.exist();
expect(req._headers.bar).to.not.exist();
expect(req1._headers.banana).to.exist();
expect(req1._headers.foo).to.exist();
expect(req1._headers.bar).to.not.exist();
req = wreckB.request('get', 'http://localhost/', { headers: { banana: 911 } }, function (err, res) {
var req2 = wreckB.request('get', 'http://localhost/', { headers: { banana: 911 } }, function (err) {
expect(req._headers.banana).to.exist();
expect(req._headers.foo).to.not.exist();
expect(req._headers.bar).to.exist();
expect(req2._headers.banana).to.exist();
expect(req2._headers.foo).to.not.exist();
expect(req2._headers.bar).to.exist();
req = wreckAB.request('get', 'http://localhost/', { headers: { banana: 911 } }, function (err, res) {
var req3 = wreckAB.request('get', 'http://localhost/', { headers: { banana: 911 } }, function (err) {
expect(req._headers.banana).to.exist();
expect(req._headers.foo).to.exist();
expect(req._headers.bar).to.exist();
expect(req3._headers.banana).to.exist();
expect(req3._headers.foo).to.exist();
expect(req3._headers.bar).to.exist();

@@ -1783,0 +1886,0 @@ done();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc