Comparing version 2.77.0 to 2.78.0
## Change Log | ||
### v2.78.0 (2016/11/03) | ||
- [#2447](https://github.com/request/request/pull/2447) Always set request timeout on keep-alive connections (@mscdex) | ||
### v2.77.0 (2016/11/03) | ||
@@ -513,4 +516,2 @@ - [#2439](https://github.com/request/request/pull/2439) Fix socket 'connect' listener handling (@mscdex) | ||
- [#630](https://github.com/request/request/pull/630) Send random cnonce for HTTP Digest requests (@wprl) | ||
### v2.27.0 (2013/08/15) | ||
- [#619](https://github.com/request/request/pull/619) decouple things a bit (@joaojeronimo) | ||
@@ -517,0 +518,0 @@ - [#613](https://github.com/request/request/pull/613) Fixes #583, moved initialization of self.uri.pathname (@lexander) |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.77.0", | ||
"version": "2.78.0", | ||
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>", | ||
@@ -13,0 +13,0 @@ "repository": { |
@@ -769,48 +769,55 @@ 'use strict' | ||
self.req.on('socket', function(socket) { | ||
var setReqTimeout = function() { | ||
// This timeout sets the amount of time to wait *between* bytes sent | ||
// from the server once connected. | ||
// | ||
// In particular, it's useful for erroring if the server fails to send | ||
// data halfway through streaming a response. | ||
self.req.setTimeout(timeout, function () { | ||
if (self.req) { | ||
self.abort() | ||
var e = new Error('ESOCKETTIMEDOUT') | ||
e.code = 'ESOCKETTIMEDOUT' | ||
e.connect = false | ||
self.emit('error', e) | ||
} | ||
}) | ||
} | ||
// `._connecting` was the old property which was made public in node v6.1.0 | ||
var isConnecting = socket._connecting || socket.connecting | ||
// Only start the connection timer if we're actually connecting a new | ||
// socket, otherwise if we're already connected (because this is a | ||
// keep-alive connection) do not bother. This is important since we won't | ||
// get a 'connect' event for an already connected socket. | ||
if (timeout !== undefined && isConnecting) { | ||
var onReqSockConnect = function() { | ||
socket.removeListener('connect', onReqSockConnect) | ||
clearTimeout(self.timeoutTimer) | ||
self.timeoutTimer = null | ||
// Set an additional timeout on the socket, via the `setsockopt` syscall. | ||
// This timeout sets the amount of time to wait *between* bytes sent | ||
// from the server once connected. | ||
// | ||
// In particular, it's useful for erroring if the server fails to send | ||
// data halfway through streaming a response. | ||
self.req.setTimeout(timeout, function () { | ||
if (self.req) { | ||
self.abort() | ||
var e = new Error('ESOCKETTIMEDOUT') | ||
e.code = 'ESOCKETTIMEDOUT' | ||
e.connect = false | ||
self.emit('error', e) | ||
} | ||
}) | ||
} | ||
if (timeout !== undefined) { | ||
// Only start the connection timer if we're actually connecting a new | ||
// socket, otherwise if we're already connected (because this is a | ||
// keep-alive connection) do not bother. This is important since we won't | ||
// get a 'connect' event for an already connected socket. | ||
if (isConnecting) { | ||
var onReqSockConnect = function() { | ||
socket.removeListener('connect', onReqSockConnect) | ||
clearTimeout(self.timeoutTimer) | ||
self.timeoutTimer = null | ||
setReqTimeout() | ||
} | ||
socket.on('connect', onReqSockConnect) | ||
socket.on('connect', onReqSockConnect) | ||
self.req.on('error', function(err) { | ||
socket.removeListener('connect', onReqSockConnect) | ||
}) | ||
self.req.on('error', function(err) { | ||
socket.removeListener('connect', onReqSockConnect) | ||
}) | ||
// Set a timeout in memory - this block will throw if the server takes more | ||
// than `timeout` to write the HTTP status and headers (corresponding to | ||
// the on('response') event on the client). NB: this measures wall-clock | ||
// time, not the time between bytes sent by the server. | ||
self.timeoutTimer = setTimeout(function () { | ||
socket.removeListener('connect', onReqSockConnect) | ||
self.abort() | ||
var e = new Error('ETIMEDOUT') | ||
e.code = 'ETIMEDOUT' | ||
e.connect = true | ||
self.emit('error', e) | ||
}, timeout) | ||
// Set a timeout in memory - this block will throw if the server takes more | ||
// than `timeout` to write the HTTP status and headers (corresponding to | ||
// the on('response') event on the client). NB: this measures wall-clock | ||
// time, not the time between bytes sent by the server. | ||
self.timeoutTimer = setTimeout(function () { | ||
socket.removeListener('connect', onReqSockConnect) | ||
self.abort() | ||
var e = new Error('ETIMEDOUT') | ||
e.code = 'ETIMEDOUT' | ||
e.connect = true | ||
self.emit('error', e) | ||
}, timeout) | ||
} else { | ||
// We're already connected | ||
setReqTimeout() | ||
} | ||
} | ||
@@ -817,0 +824,0 @@ self.emit('socket', socket) |
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
198474
2407