Template Upload
This commit is contained in:
55
node_modules/timed-out/index.js
generated
vendored
Normal file
55
node_modules/timed-out/index.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
'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.call(socket);
|
||||
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.
|
||||
this.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);
|
||||
};
|
21
node_modules/timed-out/license
generated
vendored
Normal file
21
node_modules/timed-out/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
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.
|
95
node_modules/timed-out/package.json
generated
vendored
Normal file
95
node_modules/timed-out/package.json
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"timed-out@^3.0.0",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\got"
|
||||
]
|
||||
],
|
||||
"_from": "timed-out@>=3.0.0-0 <4.0.0-0",
|
||||
"_id": "timed-out@3.1.3",
|
||||
"_inCache": true,
|
||||
"_location": "/timed-out",
|
||||
"_nodeVersion": "6.9.2",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/timed-out-3.1.3.tgz_1482989351228_0.5811902172863483"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "floatdrop@gmail.com",
|
||||
"name": "floatdrop"
|
||||
},
|
||||
"_npmVersion": "3.10.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "timed-out",
|
||||
"raw": "timed-out@^3.0.0",
|
||||
"rawSpec": "^3.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=3.0.0-0 <4.0.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/got"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/timed-out/-/timed-out-3.1.3.tgz",
|
||||
"_shasum": "95860bfcc5c76c277f8f8326fd0f5b2e20eba217",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "timed-out@^3.0.0",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\got",
|
||||
"author": {
|
||||
"email": "floatdrop@gmail.com",
|
||||
"name": "Vsevolod Strukchinsky"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/floatdrop/timed-out/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Emit `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"xo": "^0.16.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "95860bfcc5c76c277f8f8326fd0f5b2e20eba217",
|
||||
"tarball": "https://registry.npmjs.org/timed-out/-/timed-out-3.1.3.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "eadea0f4c2122784a6b57f657de3a16762ec153b",
|
||||
"homepage": "https://github.com/floatdrop/timed-out#readme",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"get",
|
||||
"got",
|
||||
"http",
|
||||
"https",
|
||||
"request",
|
||||
"simple",
|
||||
"uri",
|
||||
"url",
|
||||
"util",
|
||||
"utility"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "floatdrop",
|
||||
"email": "floatdrop@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "timed-out",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/floatdrop/timed-out.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && mocha"
|
||||
},
|
||||
"version": "3.1.3"
|
||||
}
|
42
node_modules/timed-out/readme.md
generated
vendored
Normal file
42
node_modules/timed-out/readme.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# 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)
|
Reference in New Issue
Block a user