Comparing version 14.0.2 to 14.1.0
@@ -317,3 +317,3 @@ 'use strict'; | ||
stream.pipe(req); | ||
internals.deferPipeUntilSocketConnects(req, stream); | ||
return req; | ||
@@ -332,2 +332,27 @@ } | ||
internals.deferPipeUntilSocketConnects = function (req, stream) { | ||
const onSocket = (socket) => { | ||
if (!socket.connecting) { | ||
return onSocketConnect(); | ||
} | ||
socket.once('connect', onSocketConnect); | ||
}; | ||
const onSocketConnect = () => { | ||
stream.pipe(req); | ||
stream.removeListener('error', onStreamError); | ||
}; | ||
const onStreamError = (err) => { | ||
req.emit('error', err); | ||
}; | ||
req.once('socket', onSocket); | ||
stream.on('error', onStreamError); | ||
}; | ||
internals.redirectMethod = function (code, method, options) { | ||
@@ -446,2 +471,10 @@ | ||
// Workaround https://github.com/nodejs/node/pull/20611 | ||
// This is covered in node 10 | ||
/* $lab:coverage:off$ */ | ||
if (res.complete) { | ||
return; | ||
} | ||
/* $lab:coverage:on$ */ | ||
return finishOnce(Boom.internal('Payload stream closed prematurely')); | ||
@@ -448,0 +481,0 @@ }; |
@@ -23,3 +23,3 @@ 'use strict'; | ||
size = size + chunk.length; | ||
data[i] = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk); | ||
data[i] = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk); | ||
} | ||
@@ -26,0 +26,0 @@ |
@@ -43,4 +43,4 @@ 'use strict'; | ||
const buffer = (this.buffers.length === 0 ? new Buffer(0) : (this.buffers.length === 1 ? this.buffers[0] : Buffer.concat(this.buffers, this.length))); | ||
const buffer = (this.buffers.length === 0 ? Buffer.alloc(0) : (this.buffers.length === 1 ? this.buffers[0] : Buffer.concat(this.buffers, this.length))); | ||
return buffer; | ||
}; |
{ | ||
"name": "wreck", | ||
"description": "HTTP Client Utilities", | ||
"version": "14.0.2", | ||
"version": "14.1.0", | ||
"repository": "git://github.com/hapijs/wreck", | ||
@@ -6,0 +6,0 @@ "main": "lib/index", |
@@ -60,3 +60,3 @@ ![wreck Logo](https://raw.github.com/hapijs/wreck/master/images/wreck.png) | ||
baseUrl: 'https://www.example.com', | ||
payload: readableStream || 'foo=bar' || new Buffer('foo=bar'), | ||
payload: readableStream || 'foo=bar' || Buffer.from('foo=bar'), | ||
headers: { /* http headers */ }, | ||
@@ -276,3 +276,3 @@ redirects: 3, | ||
```javascript | ||
const stream = Wreck.toReadableStream(new Buffer('Hello', 'ascii'), 'ascii'); | ||
const stream = Wreck.toReadableStream(Buffer.from('Hello', 'ascii'), 'ascii'); | ||
const read = stream.read(); | ||
@@ -279,0 +279,0 @@ // read -> 'Hello' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41499
521