diff options
Diffstat (limited to 'node_modules/timed-out')
-rw-r--r-- | node_modules/timed-out/index.js | 55 | ||||
-rw-r--r-- | node_modules/timed-out/license | 21 | ||||
-rw-r--r-- | node_modules/timed-out/package.json | 36 | ||||
-rw-r--r-- | node_modules/timed-out/readme.md | 42 |
4 files changed, 0 insertions, 154 deletions
diff --git a/node_modules/timed-out/index.js b/node_modules/timed-out/index.js deleted file mode 100644 index 94007a4ae..000000000 --- a/node_modules/timed-out/index.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -module.exports = function (req, time) { - if (req.timeoutTimer) { - return req; - } - - var delays = isNaN(time) ? time : {socket: time, connect: time}; - var host = req._headers ? (' to ' + req._headers.host) : ''; - - if (delays.connect !== undefined) { - req.timeoutTimer = setTimeout(function timeoutHandler() { - req.abort(); - var e = new Error('Connection timed out on request' + host); - e.code = 'ETIMEDOUT'; - req.emit('error', e); - }, delays.connect); - } - - // Clear the connection timeout timer once a socket is assigned to the - // request and is connected. - req.on('socket', function assign(socket) { - // Socket may come from Agent pool and may be already connected. - if (!(socket.connecting || socket._connecting)) { - connect(); - return; - } - - socket.once('connect', connect); - }); - - function clear() { - if (req.timeoutTimer) { - clearTimeout(req.timeoutTimer); - req.timeoutTimer = null; - } - } - - function connect() { - clear(); - - if (delays.socket !== undefined) { - // Abort the request if there is no activity on the socket for more - // than `delays.socket` milliseconds. - req.setTimeout(delays.socket, function socketTimeoutHandler() { - req.abort(); - var e = new Error('Socket timed out on request' + host); - e.code = 'ESOCKETTIMEDOUT'; - req.emit('error', e); - }); - } - } - - return req.on('error', clear); -}; diff --git a/node_modules/timed-out/license b/node_modules/timed-out/license deleted file mode 100644 index faadd5287..000000000 --- a/node_modules/timed-out/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/timed-out/package.json b/node_modules/timed-out/package.json deleted file mode 100644 index b86baa703..000000000 --- a/node_modules/timed-out/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "timed-out", - "version": "4.0.1", - "description": "Emit `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged", - "license": "MIT", - "repository": "floatdrop/timed-out", - "author": { - "name": "Vsevolod Strukchinsky", - "email": "floatdrop@gmail.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "xo && mocha" - }, - "files": [ - "index.js" - ], - "keywords": [ - "http", - "https", - "get", - "got", - "url", - "uri", - "request", - "util", - "utility", - "simple" - ], - "devDependencies": { - "mocha": "*", - "xo": "^0.16.0" - } -} diff --git a/node_modules/timed-out/readme.md b/node_modules/timed-out/readme.md deleted file mode 100644 index fa0a03565..000000000 --- a/node_modules/timed-out/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -# timed-out [](https://travis-ci.org/floatdrop/timed-out) - -> Timeout HTTP/HTTPS requests - -Emit Error object with `code` property equal `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged. - -## Usage - -```js -var get = require('http').get; -var timeout = require('timed-out'); - -var req = get('http://www.google.ru'); -timeout(req, 2000); // Set 2 seconds limit -``` - -### API - -#### timedout(request, time) - -##### request - -*Required* -Type: [`ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) - -The request to watch on. - -##### time - -*Required* -Type: `number` or `object` - -Time in milliseconds to wait for `connect` event on socket and also time to wait on inactive socket. - -Or you can pass Object with following fields: - -- `connect` - time to wait for connection -- `socket` - time to wait for activity on socket - -## License - -MIT © [Vsevolod Strukchinsky](floatdrop@gmail.com) |