add all files

This commit is contained in:
Rucus
2026-02-17 09:29:34 -06:00
parent b8c8d67c67
commit 782d203799
21925 changed files with 2433086 additions and 0 deletions

5
node_modules/hyperquest/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "iojs"

18
node_modules/hyperquest/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,18 @@
This software is released under the MIT license:
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.

20
node_modules/hyperquest/example/many_hyperquest.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var http = require('http');
var hyperquest = require('../');
var server = http.createServer(function (req, res) {
res.write(req.url.slice(1) + '\n');
setTimeout(res.end.bind(res), 3000);
});
server.listen(5000, function () {
var pending = 20;
for (var i = 0; i < 20; i++) {
var r = hyperquest('http://localhost:5000/' + i);
r.pipe(process.stdout, { end: false });
r.on('end', function () {
if (--pending === 0) server.close();
});
}
});
process.stdout.setMaxListeners(0); // turn off annoying warnings

20
node_modules/hyperquest/example/many_request.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var http = require('http');
var request = require('request');
var server = http.createServer(function (req, res) {
res.write(req.url.slice(1) + '\n');
setTimeout(res.end.bind(res), 3000);
});
server.listen(5000, function () {
var pending = 20;
for (var i = 0; i < 20; i++) {
var r = request('http://localhost:5000/' + i);
r.pipe(process.stdout, { end: false });
r.on('end', function () {
if (--pending === 0) server.close();
});
}
});
process.stdout.setMaxListeners(0); // turn off annoying warnings

2
node_modules/hyperquest/example/req.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
var hyperquest = require('../');
hyperquest('http://localhost:8000').pipe(process.stdout);

153
node_modules/hyperquest/index.js generated vendored Normal file
View File

@@ -0,0 +1,153 @@
var url = require('url');
var http = require('http');
var https = require('https');
var through = require('through2');
var duplexer = require('duplexer2');
var bufferFrom = require('buffer-from');
module.exports = hyperquest;
function bind (obj, fn) {
var args = Array.prototype.slice.call(arguments, 2);
return function () {
var argv = args.concat(Array.prototype.slice.call(arguments));
return fn.apply(obj, argv);
}
}
function hyperquest (uri, opts, cb, extra) {
if (typeof uri === 'object') {
cb = opts;
opts = uri;
uri = undefined;
}
if (typeof opts === 'function') {
cb = opts;
opts = undefined;
}
if (!opts) opts = {};
if (uri !== undefined) opts.uri = uri;
if (extra) opts.method = extra.method;
var req = new Req(opts);
var ws = req.duplex && through();
var rs = through();
var dup = req.duplex ? duplexer(ws, rs) : rs;
if (!req.duplex) {
rs.writable = false;
}
dup.request = req;
dup.setHeader = bind(req, req.setHeader);
dup.setLocation = bind(req, req.setLocation);
var closed = false;
dup.on('close', function () { closed = true });
process.nextTick(function () {
if (closed) return;
dup.on('close', function () { r.destroy() });
var r = req._send();
r.on('error', bind(dup, dup.emit, 'error'));
dup.emit('request', r);
r.on('response', function (res) {
dup.response = res;
dup.emit('response', res);
if (req.duplex) res.pipe(rs)
else {
res.on('data', function (buf) { rs.push(buf) });
res.on('end', function () { rs.push(null) });
}
});
if (req.duplex) {
ws.pipe(r);
}
else r.end();
});
if (cb) {
dup.on('error', cb);
dup.on('response', bind(dup, cb, null));
}
return dup;
}
hyperquest.get = hyperquest;
hyperquest.post = function (uri, opts, cb) {
return hyperquest(uri, opts, cb, { method: 'POST' });
};
hyperquest.put = function (uri, opts, cb) {
return hyperquest(uri, opts, cb, { method: 'PUT' });
};
hyperquest['delete'] = function (uri, opts, cb) {
return hyperquest(uri, opts, cb, { method: 'DELETE' });
};
function Req (opts) {
this.headers = opts.headers || {};
var method = (opts.method || 'GET').toUpperCase();
this.method = method;
this.duplex = !(method === 'GET' || method === 'HEAD');
this.auth = opts.auth;
this.options = opts;
if (opts.uri) this.setLocation(opts.uri);
}
Req.prototype._send = function () {
this._sent = true;
var headers = this.headers || {};
var u = url.parse(this.uri);
var au = u.auth || this.auth;
if (au) {
headers.authorization = 'Basic ' + bufferFrom(au).toString('base64');
}
var protocol = u.protocol || '';
var iface = protocol === 'https:' ? https : http;
var opts = {
scheme: protocol.replace(/:$/, ''),
method: this.method,
host: u.hostname,
port: Number(u.port) || (protocol === 'https:' ? 443 : 80),
path: u.path,
agent: this.options.agent || false,
headers: headers,
withCredentials: this.options.withCredentials,
localAddress: this.options.localAddress
};
if (protocol === 'https:') {
opts.pfx = this.options.pfx;
opts.key = this.options.key;
opts.cert = this.options.cert;
opts.ca = this.options.ca;
opts.ciphers = this.options.ciphers;
opts.rejectUnauthorized = this.options.rejectUnauthorized;
opts.secureProtocol = this.options.secureProtocol;
}
var req = iface.request(opts);
var timeout = this.options.timeout || 2147483647;
if (req.setTimeout) req.setTimeout(timeout);
return req;
};
Req.prototype.setHeader = function (key, value) {
if (this._sent) throw new Error('request already sent');
this.headers[key] = value;
return this;
};
Req.prototype.setLocation = function (uri) {
this.uri = uri;
return this;
};

40
node_modules/hyperquest/package.json generated vendored Normal file
View File

@@ -0,0 +1,40 @@
{
"name": "hyperquest",
"version": "2.1.3",
"description": "make streaming http requests",
"main": "index.js",
"dependencies": {
"buffer-from": "^0.1.1",
"duplexer2": "~0.0.2",
"through2": "~0.6.3"
},
"devDependencies": {
"tape": "^3.0.1"
},
"scripts": {
"test": "tape test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/substack/hyperquest.git"
},
"homepage": "https://github.com/substack/hyperquest",
"keywords": [
"stream",
"http",
"transport",
"request",
"get",
"post",
"put",
"delete",
"duplex",
"pooling"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT"
}

269
node_modules/hyperquest/readme.markdown generated vendored Normal file
View File

@@ -0,0 +1,269 @@
# hyperquest
treat http requests as a streaming transport
[![build status](https://secure.travis-ci.org/substack/hyperquest.png)](http://travis-ci.org/substack/hyperquest)
The hyperquest api is a subset of [request](https://github.com/mikeal/request).
This module works in the browser with [browserify](http://browserify.org).
# rant
![animated gif rant](http://substack.net/images/substack.gif)
This module disables a lot of infuriating things about core http that WILL cause
bugs in your application if you think of http as just another kind of stream:
* http requests have a default idle timeout of 2 minutes. This is terrible if
you just want to pipe together a bunch of persistent backend processes over
http.
* There is a default connection pool of 5 requests. If you have 5 or more extant
http requests, any additional requests will HANG for NO GOOD REASON.
hyperquest turns these annoyances off so you can just pretend that core http is
just a fancier version of tcp and not the horrible monstrosity that it actually
is.
I have it on good authority that these annoyances will be fixed in node 0.12.
# example
# simple streaming GET
``` js
var hyperquest = require('hyperquest');
hyperquest('http://localhost:8000').pipe(process.stdout);
```
```
$ node example/req.js
beep boop
```
# pooling is evil
Now to drive the point home about pooling being evil and almost always never
what you want ever.
[request](https://github.com/mikeal/request)
has its own forever agent thing that works pretty much the same as node core
http.request: the wrong, horrible, broken way.
For instance, the following request code takes 12+ seconds to finish:
``` js
var http = require('http');
var request = require('request');
var server = http.createServer(function (req, res) {
res.write(req.url.slice(1) + '\n');
setTimeout(res.end.bind(res), 3000);
});
server.listen(5000, function () {
var pending = 20;
for (var i = 0; i < 20; i++) {
var r = request('http://localhost:5000/' + i);
r.pipe(process.stdout, { end: false });
r.on('end', function () {
if (--pending === 0) server.close();
});
}
});
process.stdout.setMaxListeners(0); // turn off annoying warnings
```
```
substack : example $ time node many_request.js
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
real 0m12.423s
user 0m0.424s
sys 0m0.048s
```
Surprising? YES. This is pretty much never what you want, particularly if you
have a lot of streaming http API endpoints. Your code will just *HANG* once the
connection pool fills up and it won't start working again until some connections
die for whatever reason. I have encountered this so many times in production
instances and it is SO hard to track down reliably.
Compare to using hyperquest, which is exactly the same code but it takes 3
seconds instead of 12 to finish because it's not completely self-crippled like
request and core http.request.
``` js
var http = require('http');
var hyperquest = require('hyperquest');
var server = http.createServer(function (req, res) {
res.write(req.url.slice(1) + '\n');
setTimeout(res.end.bind(res), 3000);
});
server.listen(5000, function () {
var pending = 20;
for (var i = 0; i < 20; i++) {
var r = hyperquest('http://localhost:5000/' + i);
r.pipe(process.stdout, { end: false });
r.on('end', function () {
if (--pending === 0) server.close();
});
}
});
process.stdout.setMaxListeners(0); // turn off annoying warnings
```
```
$ time node many_hyperquest.js
0
1
2
3
4
5
6
8
9
7
10
11
12
13
14
15
16
17
18
19
real 0m3.284s
user 0m0.288s
sys 0m0.060s
```
So the other thing is, the justification I've heard supporting this horrible
limit-of-5 pooling behavior is "performance". The first example which has been
tuned for "performance" takes 12 seconds. The second example that removes these
"performance" enhancements takes 3. Some performance improvement INDEED!
# methods
``` js
var hyperquest = require('hyperquest');
```
## var req = hyperquest(uri, opts={}, cb)
Create an outgoing http request to `uri` or `opts.uri`.
You need not pass any arguments here since there are setter methods documented
below.
Return a readable or duplex stream depending on the `opts.method`.
Default option values:
* opts.method - `"GET"`
* opts.headers - `{}`
* opts.auth - undefined, but is set automatically when the `uri` has an auth
string in it such as `"http://user:passwd@host"`. `opts.auth` is of the form
`"user:pass"`, just like `http.request()`.
* opts.agent - `false`
* opts.timeout - `Math.pow(2, 32) * 1000` The value is passed as an argument
to the underlying `req.setTimeout()` function.
* opts.localAddress - local interface to bind for network connections
(Node.js only)
In https mode, you can specify options to the underlying `tls.connect()` call:
* opts.pfx
* opts.key
* opts.cert
* opts.ca
* opts.ciphers
* opts.rejectUnauthorized
* opts.secureProtocol
The request does not go through until the `nextTick` so you can set values
outside of the `opts` so long as they are called on the same tick.
Optionally you can pass a `cb(err, res)` to set up listeners for `'error'` and
`'response'` events in one place.
Note that the optional `cb` is NOT like
[request](https://github.com/mikeal/request)
in that hyperquest will not buffer content for you or decode to json or any such
magical thing.
## req.setHeader(key, value);
Set an outgoing header `key` to `value`.
## req.setLocation(uri);
Set the location if you didn't specify it in the `hyperquest()` call.
## var req = hyperquest.get(uri, opts, cb)
Return a readable stream from `hyperquest(..., { method: 'GET' })`.
## var req = hyperquest.put(uri, opts, cb)
Return a duplex stream from `hyperquest(..., { method: 'PUT' })`.
## var req = hyperquest.post(uri, opts, cb)
Return a duplex stream from `hyperquest(..., { method: 'POST' })`.
## var req = hyperquest.delete(uri, opts, cb)
Return a readable stream from `hyperquest(..., { method: 'DELETE' })`.
# events
## req.on('request', function (req) {})
The `'request'` event is fired with the *ClientRequest* object created
as a result of the underlying `http.request()` call.
## req.on('response', function (res) {})
The `'response'` event is forwarded from the underlying `http.request()`.
## req.on('error', function (res) {})
The `'error'` event is forwarded from the underlying `http.request()`.
# install
With [npm](https://npmjs.org) do:
```
npm install hyperquest
```
# license
MIT

51
node_modules/hyperquest/test/auth.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var bufferFrom = require('buffer-from');
var server = http.createServer(function (req, res) {
var au = req.headers.authorization;
if (!au) return res.end('ACCESS DENIED');
var buf = bufferFrom(au.replace(/^Basic\s+/, ''), 'base64');
var s = buf.toString().split(':');
if (s[0] === 'moo' && s[1] === 'hax') {
res.end('WELCOME TO ZOMBO COM');
}
else {
res.end('ACCESS DENIED!!!');
}
});
test('basic auth', function (t) {
t.plan(3);
server.listen(0, function () {
var port = server.address().port;
checkUnauth(t, port);
checkValid(t, port);
checkInvalid(t, port);
});
t.on('end', server.close.bind(server));
});
function checkUnauth (t, port) {
var r = hyperquest('http://localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'ACCESS DENIED') });
}
function checkValid (t, port) {
var r = hyperquest('http://moo:hax@localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') });
}
function checkInvalid (t, port) {
var r = hyperquest('http://beep:boop@localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') });
}

51
node_modules/hyperquest/test/auth_encoded.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var bufferFrom = require('buffer-from');
var server = http.createServer(function (req, res) {
var au = req.headers.authorization;
if (!au) return res.end('ACCESS DENIED');
var buf = bufferFrom(au.replace(/^Basic\s+/, ''), 'base64');
var s = buf.toString().split(':');
if (s[0] === 'm##' && s[1] === 'h@x') {
res.end('WELCOME TO ZOMBO COM');
}
else {
res.end('ACCESS DENIED!!!');
}
});
test('basic auth with escaped params', function (t) {
t.plan(3);
server.listen(0, function () {
var port = server.address().port;
checkUnauth(t, port);
checkValid(t, port);
checkInvalid(t, port);
});
t.on('end', server.close.bind(server));
});
function checkUnauth (t, port) {
var r = hyperquest('http://localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'ACCESS DENIED') });
}
function checkValid (t, port) {
var r = hyperquest('http://m%23%23:h%40x@localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') });
}
function checkInvalid (t, port) {
var r = hyperquest('http://beep:boop@localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') });
}

51
node_modules/hyperquest/test/auth_opt.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var bufferFrom = require('buffer-from');
var server = http.createServer(function (req, res) {
var au = req.headers.authorization;
if (!au) return res.end('ACCESS DENIED');
var buf = bufferFrom(au.replace(/^Basic\s+/, ''), 'base64');
var s = buf.toString().split(':');
if (s[0] === 'moo' && s[1] === 'hax') {
res.end('WELCOME TO ZOMBO COM');
}
else {
res.end('ACCESS DENIED!!!');
}
});
test('basic opts.auth', function (t) {
t.plan(3);
server.listen(0, function () {
var port = server.address().port;
checkUnauth(t, port);
checkValid(t, port);
checkInvalid(t, port);
});
t.on('end', server.close.bind(server));
});
function checkUnauth (t, port) {
var r = hyperquest('http://localhost:' + port);
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'ACCESS DENIED') });
}
function checkValid (t, port) {
var r = hyperquest('http://localhost:' + port, { auth: 'moo:hax' });
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'WELCOME TO ZOMBO COM') });
}
function checkInvalid (t, port) {
var r = hyperquest('http://localhost:' + port, { auth: 'beep:boop' });
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () { t.equal(data, 'ACCESS DENIED!!!') });
}

37
node_modules/hyperquest/test/get.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var through = require('through2');
var server = http.createServer(function (req, res) {
res.setHeader('content-type', 'text/robot-speak');
res.end('beep boop');
});
test('get', function (t) {
t.plan(3);
server.listen(0, function () {
var port = server.address().port;
check(t, port);
});
t.on('end', server.close.bind(server));
});
function check (t, port) {
var r = hyperquest('http://localhost:' + port);
r.pipe(through(write, end));
r.on('request', function (req) {
t.ok(req);
});
r.on('response', function (res) {
t.equal(res.headers['content-type'], 'text/robot-speak');
});
var data = '';
function write (buf, enc, cb) { data += buf; cb() }
function end () {
t.equal(data, 'beep boop');
}
}

34
node_modules/hyperquest/test/many.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var through = require('through2');
var server = http.createServer(function (req, res) {
res.write('beep boop');
});
test('more than 5 pending connections', function (t) {
t.plan(20);
var pending = [];
server.listen(0, function () {
var port = server.address().port;
for (var i = 0; i < 20; i++) {
pending.push(check(t, port));
}
});
t.on('end', function () {
pending.forEach(function (p) { p.destroy() });
server.close();
});
});
function check (t, port) {
var r = hyperquest('http://localhost:' + port);
var data = '';
r.pipe(through(function (buf, enc, cb) { data += buf; cb() }));
setTimeout(function () {
t.equal(data, 'beep boop');
}, 200);
return r;
}

34
node_modules/hyperquest/test/opts.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var through = require('through2');
var server = http.createServer(function (req, res) {
res.setHeader('content-type', 'text/robot-speak');
res.end('beep boop');
});
test('1st-arg options', function (t) {
t.plan(2);
server.listen(0, function () {
var port = server.address().port;
check(t, port);
});
t.on('end', server.close.bind(server));
});
function check (t, port) {
var r = hyperquest(
{ uri: 'http://localhost:' + port },
function (err, res) {
t.equal(res.headers['content-type'], 'text/robot-speak');
}
);
r.pipe(through(write, end));
var data = '';
function write (buf, enc, cb) { data += buf; cb() }
function end () {
t.equal(data, 'beep boop');
}
}

39
node_modules/hyperquest/test/post.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var through = require('through2');
var server = http.createServer(function (req, res) {
req.pipe(through(function (buf, enc, cb) {
this.push(String(buf).toUpperCase());
cb();
})).pipe(res);
});
test('post', function (t) {
t.plan(1);
server.listen(0, function () {
var port = server.address().port;
check(t, port);
});
t.on('end', server.close.bind(server));
});
function check (t, port) {
var r = hyperquest.post('http://localhost:' + port);
r.pipe(through(write, end));
setTimeout(function () {
r.write('beep ');
}, 50);
setTimeout(function () {
r.end('boop.');
}, 100);
var data = '';
function write (buf, enc, cb) { data += buf; cb() }
function end () {
t.equal(data, 'BEEP BOOP.');
}
}

31
node_modules/hyperquest/test/post_immediate.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var through = require('through2');
var server = http.createServer(function (req, res) {
req.pipe(through(function (buf, enc, cb) {
this.push(String(buf).toUpperCase());
cb();
})).pipe(res);
});
test('post', function (t) {
t.plan(1);
server.listen(0, function () {
var port = server.address().port;
check(t, port);
});
t.on('end', server.close.bind(server));
});
function check (t, port) {
var r = hyperquest.post('http://localhost:' + port);
r.end('beep boop.');
var data = '';
r.on('data', function (buf) { data += buf });
r.on('end', function () {
t.equal(data, 'BEEP BOOP.');
});
}

20
node_modules/hyperquest/test/readable.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var test = require('tape');
var hyperquest = require('../');
var http = require('http');
var server = http.createServer(function (req, res) { res.end() });
test('readable', function (t) {
server.listen(function () {
var port = server.address().port;
var req = hyperquest('http://localhost:' + port);
t.notOk(req.flowing);
t.ok(req._read);
req.on('data', function () {});
req.on('end', function () {
server.close();
t.end();
});
});
});

30
node_modules/hyperquest/test/set_header.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
var test = require('tape');
var http = require('http');
var hyperquest = require('../');
var through = require('through2');
test('setHeader on a request', function (t) {
t.plan(2);
var server = http.createServer(function (req, res) {
t.equal(req.headers.robot, 'party');
res.end('beep boop');
});
server.listen(0, function () {
var port = server.address().port;
check(t, port);
});
t.on('end', server.close.bind(server));
});
function check (t, port) {
var r = hyperquest('http://localhost:' + port);
r.setHeader('robot', 'party');
r.pipe(through(write, end));
var data = '';
function write (buf, enc, cb) { data += buf; cb() }
function end () {
t.equal(data, 'beep boop');
}
}