mirror of
https://github.com/bvanroll/yahoo-thing.git
synced 2025-08-29 20:12:46 +00:00
euh
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();
|
||||
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);
|
||||
};
|
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.
|
96
node_modules/timed-out/package.json
generated
vendored
Normal file
96
node_modules/timed-out/package.json
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"timed-out@^4.0.0",
|
||||
"/home/beppe/Github/yahooApi/node_modules/got"
|
||||
]
|
||||
],
|
||||
"_from": "timed-out@>=4.0.0 <5.0.0",
|
||||
"_id": "timed-out@4.0.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/timed-out",
|
||||
"_nodeVersion": "6.9.3",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/timed-out-4.0.1.tgz_1484575090971_0.24377561057917774"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "floatdrop@gmail.com",
|
||||
"name": "floatdrop"
|
||||
},
|
||||
"_npmVersion": "3.10.10",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "timed-out",
|
||||
"raw": "timed-out@^4.0.0",
|
||||
"rawSpec": "^4.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=4.0.0 <5.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/got"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
|
||||
"_shasum": "f32eacac5a175bea25d7fab565ab3ed8741ef56f",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "timed-out@^4.0.0",
|
||||
"_where": "/home/beppe/Github/yahooApi/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": "f32eacac5a175bea25d7fab565ab3ed8741ef56f",
|
||||
"tarball": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "2f00fdafb6af0a9b91fb23a04a9271766c5559a4",
|
||||
"homepage": "https://github.com/floatdrop/timed-out#readme",
|
||||
"keywords": [
|
||||
"get",
|
||||
"got",
|
||||
"http",
|
||||
"https",
|
||||
"request",
|
||||
"simple",
|
||||
"uri",
|
||||
"url",
|
||||
"util",
|
||||
"utility"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "floatdrop",
|
||||
"email": "floatdrop@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "timed-out",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/floatdrop/timed-out.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && mocha"
|
||||
},
|
||||
"version": "4.0.1"
|
||||
}
|
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