vulcan 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/vulcan/cli.rb +3 -0
- data/lib/vulcan/version.rb +1 -1
- data/server/lib/spawner.js +9 -4
- data/server/node_modules/cradle/lib/cradle.js +0 -1
- data/server/node_modules/cradle/package.json +3 -3
- data/server/node_modules/cradle/test/cache-test.js +6 -7
- data/server/node_modules/cradle/test/cradle-test.js +4 -5
- data/server/node_modules/cradle/test/response-test.js +5 -6
- data/server/node_modules/express/History.md +40 -0
- data/server/node_modules/express/Makefile +3 -9
- data/server/node_modules/express/Readme.md +3 -1
- data/server/node_modules/express/bin/express +61 -63
- data/server/node_modules/express/lib/express.js +1 -1
- data/server/node_modules/express/lib/request.js +9 -7
- data/server/node_modules/express/lib/view.js +19 -16
- data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/http.js +2 -0
- data/server/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js +135 -31
- data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +5 -1
- data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +2 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/static.js +26 -21
- data/server/node_modules/express/node_modules/connect/lib/middleware/staticCache.js +91 -38
- data/server/node_modules/express/node_modules/connect/lib/middleware/vhost.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/utils.js +11 -4
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Makefile +14 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +286 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/TODO +3 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js +70 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/post.js +43 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js +48 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/index.js +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js +61 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +377 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js +3 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js +312 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js +25 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js +6 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +22 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js +19 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +13 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md +3 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +26 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +24 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +23 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +24 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +22 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +22 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +22 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js +3 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +21 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js +72 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js +89 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js +24 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js +80 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js +104 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +715 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +50 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js +45 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js +72 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js +2 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js +47 -0
- data/server/node_modules/express/node_modules/connect/package.json +7 -6
- data/server/node_modules/express/node_modules/connect/test.js +44 -31
- data/server/node_modules/express/node_modules/qs/History.md +11 -0
- data/server/node_modules/express/node_modules/qs/Makefile +1 -3
- data/server/node_modules/express/node_modules/qs/Readme.md +2 -4
- data/server/node_modules/express/node_modules/qs/lib/querystring.js +100 -74
- data/server/node_modules/express/node_modules/qs/package.json +9 -2
- data/server/node_modules/express/node_modules/qs/test/mocha.opts +2 -0
- data/server/node_modules/express/node_modules/qs/test/{parse.test.js → parse.js} +1 -2
- data/server/node_modules/express/node_modules/qs/test/{stringify.test.js → stringify.js} +0 -0
- data/server/node_modules/express/package.json +7 -7
- data/server/node_modules/express/testing/foo/app.js +35 -0
- data/server/node_modules/express/testing/foo/package.json +9 -0
- data/server/node_modules/express/testing/foo/public/stylesheets/style.css +8 -0
- data/server/node_modules/express/testing/foo/routes/index.js +10 -0
- data/server/node_modules/express/testing/foo/views/index.jade +2 -0
- data/server/node_modules/express/testing/foo/views/layout.jade +6 -0
- data/server/node_modules/express/testing/index.js +31 -5
- data/server/node_modules/express/testing/public/test.txt +2971 -0
- data/server/node_modules/express/testing/views/page.html +1 -0
- data/server/node_modules/express/testing/views/page.jade +3 -0
- data/server/node_modules/express/testing/views/test.md +1 -0
- data/server/node_modules/express/testing/views/user/index.jade +1 -0
- data/server/node_modules/express/testing/views/user/list.jade +1 -0
- data/server/node_modules/node-uuid/README.md +166 -67
- data/server/node_modules/node-uuid/benchmark/README.md +53 -0
- data/server/node_modules/node-uuid/benchmark/bench.gnu +174 -0
- data/server/node_modules/node-uuid/benchmark/bench.sh +34 -0
- data/server/node_modules/node-uuid/{test → benchmark}/benchmark-native.c +0 -0
- data/server/node_modules/node-uuid/benchmark/benchmark.js +84 -0
- data/server/node_modules/node-uuid/package.json +5 -3
- data/server/node_modules/node-uuid/test/benchmark-native +0 -0
- data/server/node_modules/node-uuid/test/compare_v1.js +63 -0
- data/server/node_modules/node-uuid/test/test.html +3 -0
- data/server/node_modules/node-uuid/test/test.js +214 -57
- data/server/node_modules/node-uuid/uuid.js +225 -56
- data/server/node_modules/restler/README.md +20 -7
- data/server/node_modules/restler/bin/restler +1 -1
- data/server/node_modules/restler/lib/multipartform.js +9 -8
- data/server/node_modules/restler/lib/restler.js +64 -22
- data/server/node_modules/restler/package.json +2 -2
- data/server/node_modules/restler/test/restler.js +22 -2
- data/server/node_modules/restler/test/test_helper.js +20 -1
- data/server/package.json +8 -8
- data/server/web.js +22 -6
- metadata +72 -82
- data/server/node_modules/cradle/node_modules/vows/LICENSE +0 -20
- data/server/node_modules/cradle/node_modules/vows/Makefile +0 -7
- data/server/node_modules/cradle/node_modules/vows/README.md +0 -39
- data/server/node_modules/cradle/node_modules/vows/bin/vows +0 -515
- data/server/node_modules/cradle/node_modules/vows/lib/assert/error.js +0 -27
- data/server/node_modules/cradle/node_modules/vows/lib/assert/macros.js +0 -215
- data/server/node_modules/cradle/node_modules/vows/lib/assert/utils.js +0 -77
- data/server/node_modules/cradle/node_modules/vows/lib/vows.js +0 -193
- data/server/node_modules/cradle/node_modules/vows/lib/vows/console.js +0 -131
- data/server/node_modules/cradle/node_modules/vows/lib/vows/context.js +0 -55
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/file.js +0 -29
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +0 -2
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +0 -61
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-html.js +0 -54
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-json.js +0 -54
- data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-plain.js +0 -38
- data/server/node_modules/cradle/node_modules/vows/lib/vows/extras.js +0 -28
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/dot-matrix.js +0 -67
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/json.js +0 -16
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/silent.js +0 -8
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/spec.js +0 -44
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/watch.js +0 -39
- data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/xunit.js +0 -90
- data/server/node_modules/cradle/node_modules/vows/lib/vows/suite.js +0 -319
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/LICENSE +0 -20
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/Makefile +0 -4
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/README.md +0 -72
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/lib/eyes.js +0 -233
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/package.json +0 -14
- data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/test/eyes-test.js +0 -55
- data/server/node_modules/cradle/node_modules/vows/package.json +0 -14
- data/server/node_modules/cradle/node_modules/vows/test/assert-test.js +0 -135
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/failing.js +0 -18
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/log.js +0 -18
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/passing.js +0 -17
- data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/stderr.js +0 -18
- data/server/node_modules/cradle/node_modules/vows/test/isolate-test.js +0 -140
- data/server/node_modules/cradle/node_modules/vows/test/testInherit.js +0 -133
- data/server/node_modules/cradle/node_modules/vows/test/vows-error-test.js +0 -51
- data/server/node_modules/cradle/node_modules/vows/test/vows-test.js +0 -374
- data/server/node_modules/express/node_modules/qs/support/expresso/History.md +0 -128
- data/server/node_modules/express/node_modules/qs/support/expresso/Makefile +0 -53
- data/server/node_modules/express/node_modules/qs/support/expresso/Readme.md +0 -61
- data/server/node_modules/express/node_modules/qs/support/expresso/bin/expresso +0 -856
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/api.html +0 -1080
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.html +0 -377
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.md +0 -290
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html +0 -3
- data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html +0 -42
- data/server/node_modules/express/node_modules/qs/support/expresso/lib/bar.js +0 -4
- data/server/node_modules/express/node_modules/qs/support/expresso/lib/foo.js +0 -16
- data/server/node_modules/express/node_modules/qs/support/expresso/package.json +0 -12
- data/server/node_modules/express/node_modules/qs/support/expresso/test/assert.test.js +0 -91
- data/server/node_modules/express/node_modules/qs/support/expresso/test/async.test.js +0 -12
- data/server/node_modules/express/node_modules/qs/support/expresso/test/bar.test.js +0 -13
- data/server/node_modules/express/node_modules/qs/support/expresso/test/foo.test.js +0 -14
- data/server/node_modules/express/node_modules/qs/support/expresso/test/http.test.js +0 -146
- data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js +0 -39
- data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js +0 -48
- data/server/node_modules/express/node_modules/qs/support/should/History.md +0 -22
- data/server/node_modules/express/node_modules/qs/support/should/Makefile +0 -6
- data/server/node_modules/express/node_modules/qs/support/should/Readme.md +0 -248
- data/server/node_modules/express/node_modules/qs/support/should/examples/runner.js +0 -53
- data/server/node_modules/express/node_modules/qs/support/should/index.js +0 -2
- data/server/node_modules/express/node_modules/qs/support/should/lib/eql.js +0 -91
- data/server/node_modules/express/node_modules/qs/support/should/lib/should.js +0 -548
- data/server/node_modules/express/node_modules/qs/support/should/package.json +0 -8
- data/server/node_modules/express/node_modules/qs/support/should/test/should.test.js +0 -358
- data/server/node_modules/express/testing/views/users.jade +0 -1
- data/server/node_modules/node-uuid/test/benchmark.js +0 -27
|
@@ -1,80 +1,249 @@
|
|
|
1
|
+
// node-uuid/uuid.js
|
|
2
|
+
//
|
|
3
|
+
// Copyright (c) 2010 Robert Kieffer
|
|
4
|
+
// Dual licensed under the MIT and GPL licenses.
|
|
5
|
+
// Documentation and details at https://github.com/broofa/node-uuid
|
|
1
6
|
(function() {
|
|
2
|
-
|
|
3
|
-
* Generate a RFC4122(v4) UUID
|
|
4
|
-
*
|
|
5
|
-
* Documentation at https://github.com/broofa/node-uuid
|
|
6
|
-
*/
|
|
7
|
+
var _global = this;
|
|
7
8
|
|
|
8
|
-
//
|
|
9
|
-
|
|
9
|
+
// Unique ID creation requires a high quality random # generator, but
|
|
10
|
+
// Math.random() does not guarantee "cryptographic quality". So we feature
|
|
11
|
+
// detect for more robust APIs, normalizing each method to return 128-bits
|
|
12
|
+
// (16 bytes) of random data.
|
|
13
|
+
var mathRNG, nodeRNG, whatwgRNG;
|
|
14
|
+
|
|
15
|
+
// Math.random()-based RNG. All platforms, very fast, unknown quality
|
|
16
|
+
var _rndBytes = new Array(16);
|
|
17
|
+
mathRNG = function() {
|
|
18
|
+
var r, b = _rndBytes, i = 0;
|
|
19
|
+
|
|
20
|
+
for (var i = 0, r; i < 16; i++) {
|
|
21
|
+
if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
|
|
22
|
+
b[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return b;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
|
|
29
|
+
// WebKit only (currently), moderately fast, high quality
|
|
30
|
+
if (_global.crypto && crypto.getRandomValues) {
|
|
31
|
+
var _rnds = new Uint32Array(4);
|
|
32
|
+
whatwgRNG = function() {
|
|
33
|
+
crypto.getRandomValues(_rnds);
|
|
10
34
|
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
for (var c = 0 ; c < 16; c++) {
|
|
36
|
+
_rndBytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
|
|
37
|
+
}
|
|
38
|
+
return _rndBytes;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html
|
|
43
|
+
// Node.js only, moderately fast, high quality
|
|
44
|
+
try {
|
|
45
|
+
var _rb = require('crypto').randomBytes;
|
|
46
|
+
nodeRNG = _rb && function() {
|
|
47
|
+
return _rb(16);
|
|
48
|
+
};
|
|
49
|
+
} catch (e) {}
|
|
50
|
+
|
|
51
|
+
// Select RNG with best quality
|
|
52
|
+
var _rng = nodeRNG || whatwgRNG || mathRNG;
|
|
13
53
|
|
|
14
|
-
//
|
|
15
|
-
var
|
|
16
|
-
|
|
54
|
+
// Buffer class to use
|
|
55
|
+
var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;
|
|
56
|
+
|
|
57
|
+
// Maps for number <-> hex string conversion
|
|
58
|
+
var _byteToHex = [];
|
|
59
|
+
var _hexToByte = {};
|
|
17
60
|
for (var i = 0; i < 256; i++) {
|
|
18
|
-
|
|
19
|
-
|
|
61
|
+
_byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
|
62
|
+
_hexToByte[_byteToHex[i]] = i;
|
|
20
63
|
}
|
|
21
64
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var i = 0,
|
|
25
|
-
|
|
26
|
-
|
|
65
|
+
// **`parse()` - Parse a UUID into it's component bytes**
|
|
66
|
+
function parse(s, buf, offset) {
|
|
67
|
+
var i = (buf && offset) || 0, ii = 0;
|
|
68
|
+
|
|
69
|
+
buf = buf || [];
|
|
70
|
+
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(byte) {
|
|
71
|
+
if (ii < 16) { // Don't overflow!
|
|
72
|
+
buf[i + ii++] = _hexToByte[byte];
|
|
73
|
+
}
|
|
27
74
|
});
|
|
75
|
+
|
|
76
|
+
// Zero out remaining bytes if string was short
|
|
77
|
+
while (ii < 16) {
|
|
78
|
+
buf[i + ii++] = 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
28
81
|
return buf;
|
|
29
82
|
}
|
|
30
83
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
84
|
+
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
|
|
85
|
+
function unparse(buf, offset) {
|
|
86
|
+
var i = offset || 0, bth = _byteToHex;
|
|
87
|
+
return bth[buf[i++]] + bth[buf[i++]] +
|
|
88
|
+
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
|
89
|
+
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
|
90
|
+
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
|
91
|
+
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
|
92
|
+
bth[buf[i++]] + bth[buf[i++]] +
|
|
93
|
+
bth[buf[i++]] + bth[buf[i++]] +
|
|
94
|
+
bth[buf[i++]] + bth[buf[i++]];
|
|
39
95
|
}
|
|
40
96
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
97
|
+
// **`v1()` - Generate time-based UUID**
|
|
98
|
+
//
|
|
99
|
+
// Inspired by https://github.com/LiosK/UUID.js
|
|
100
|
+
// and http://docs.python.org/library/uuid.html
|
|
101
|
+
|
|
102
|
+
// random #'s we need to init node and clockseq
|
|
103
|
+
var _seedBytes = _rng();
|
|
104
|
+
|
|
105
|
+
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
106
|
+
var _nodeId = [
|
|
107
|
+
_seedBytes[0] | 0x01,
|
|
108
|
+
_seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
// Per 4.2.2, randomize (14 bit) clockseq
|
|
112
|
+
var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
|
|
113
|
+
|
|
114
|
+
// Previous uuid creation time
|
|
115
|
+
var _lastMSecs = 0, _lastNSecs = 0;
|
|
116
|
+
|
|
117
|
+
// See https://github.com/broofa/node-uuid for API details
|
|
118
|
+
function v1(options, buf, offset) {
|
|
44
119
|
var i = buf && offset || 0;
|
|
120
|
+
var b = buf || [];
|
|
121
|
+
|
|
122
|
+
options = options || {};
|
|
123
|
+
|
|
124
|
+
var clockseq = options.clockseq != null ? options.clockseq : _clockseq;
|
|
125
|
+
|
|
126
|
+
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
|
127
|
+
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
|
128
|
+
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
|
129
|
+
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
130
|
+
var msecs = options.msecs != null ? options.msecs : new Date().getTime();
|
|
131
|
+
|
|
132
|
+
// Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
133
|
+
// cycle to simulate higher resolution clock
|
|
134
|
+
var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
|
|
135
|
+
|
|
136
|
+
// Time since last uuid creation (in msecs)
|
|
137
|
+
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
|
|
45
138
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
b[i++] = r>>>24 & ff;
|
|
51
|
-
r = Math.random()*b32;
|
|
52
|
-
b[i++] = r & ff;
|
|
53
|
-
b[i++] = r>>>8 & ff;
|
|
54
|
-
b[i++] = r>>>16 & 0x0f | 0x40; // See RFC4122 sect. 4.1.3
|
|
55
|
-
b[i++] = r>>>24 & ff;
|
|
56
|
-
r = Math.random()*b32;
|
|
57
|
-
b[i++] = r & 0x3f | 0x80; // See RFC4122 sect. 4.4
|
|
58
|
-
b[i++] = r>>>8 & ff;
|
|
59
|
-
b[i++] = r>>>16 & ff;
|
|
60
|
-
b[i++] = r>>>24 & ff;
|
|
61
|
-
r = Math.random()*b32;
|
|
62
|
-
b[i++] = r & ff;
|
|
63
|
-
b[i++] = r>>>8 & ff;
|
|
64
|
-
b[i++] = r>>>16 & ff;
|
|
65
|
-
b[i++] = r>>>24 & ff;
|
|
66
|
-
|
|
67
|
-
return fmt === undefined ? unparse(b) : b;
|
|
68
|
-
};
|
|
139
|
+
// Per 4.2.1.2, Bump clockseq on clock regression
|
|
140
|
+
if (dt < 0 && options.clockseq == null) {
|
|
141
|
+
clockseq = clockseq + 1 & 0x3fff;
|
|
142
|
+
}
|
|
69
143
|
|
|
144
|
+
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
|
145
|
+
// time interval
|
|
146
|
+
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
|
|
147
|
+
nsecs = 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Per 4.2.1.2 Throw error if too many uuids are requested
|
|
151
|
+
if (nsecs >= 10000) {
|
|
152
|
+
throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_lastMSecs = msecs;
|
|
156
|
+
_lastNSecs = nsecs;
|
|
157
|
+
_clockseq = clockseq;
|
|
158
|
+
|
|
159
|
+
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
|
160
|
+
msecs += 12219292800000;
|
|
161
|
+
|
|
162
|
+
// `time_low`
|
|
163
|
+
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
164
|
+
b[i++] = tl >>> 24 & 0xff;
|
|
165
|
+
b[i++] = tl >>> 16 & 0xff;
|
|
166
|
+
b[i++] = tl >>> 8 & 0xff;
|
|
167
|
+
b[i++] = tl & 0xff;
|
|
168
|
+
|
|
169
|
+
// `time_mid`
|
|
170
|
+
var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
|
|
171
|
+
b[i++] = tmh >>> 8 & 0xff;
|
|
172
|
+
b[i++] = tmh & 0xff;
|
|
173
|
+
|
|
174
|
+
// `time_high_and_version`
|
|
175
|
+
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
|
176
|
+
b[i++] = tmh >>> 16 & 0xff;
|
|
177
|
+
|
|
178
|
+
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
|
179
|
+
b[i++] = clockseq >>> 8 | 0x80;
|
|
180
|
+
|
|
181
|
+
// `clock_seq_low`
|
|
182
|
+
b[i++] = clockseq & 0xff;
|
|
183
|
+
|
|
184
|
+
// `node`
|
|
185
|
+
var node = options.node || _nodeId;
|
|
186
|
+
for (var n = 0; n < 6; n++) {
|
|
187
|
+
b[i + n] = node[n];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return buf ? buf : unparse(b);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// **`v4()` - Generate random UUID**
|
|
194
|
+
|
|
195
|
+
// See https://github.com/broofa/node-uuid for API details
|
|
196
|
+
function v4(options, buf, offset) {
|
|
197
|
+
// Deprecated - 'format' argument, as supported in v1.2
|
|
198
|
+
var i = buf && offset || 0;
|
|
199
|
+
|
|
200
|
+
if (typeof(options) == 'string') {
|
|
201
|
+
buf = options == 'binary' ? new BufferClass(16) : null;
|
|
202
|
+
options = null;
|
|
203
|
+
}
|
|
204
|
+
options = options || {};
|
|
205
|
+
|
|
206
|
+
var rnds = options.random || (options.rng || _rng)();
|
|
207
|
+
|
|
208
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
209
|
+
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
210
|
+
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
211
|
+
|
|
212
|
+
// Copy bytes to buffer, if provided
|
|
213
|
+
if (buf) {
|
|
214
|
+
for (var ii = 0; ii < 16; ii++) {
|
|
215
|
+
buf[i + ii] = rnds[ii];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return buf || unparse(rnds);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Export public API
|
|
223
|
+
var uuid = v4;
|
|
224
|
+
uuid.v1 = v1;
|
|
225
|
+
uuid.v4 = v4;
|
|
70
226
|
uuid.parse = parse;
|
|
71
227
|
uuid.unparse = unparse;
|
|
72
228
|
uuid.BufferClass = BufferClass;
|
|
73
229
|
|
|
230
|
+
// Export RNG options
|
|
231
|
+
uuid.mathRNG = mathRNG;
|
|
232
|
+
uuid.nodeRNG = nodeRNG;
|
|
233
|
+
uuid.whatwgRNG = whatwgRNG;
|
|
234
|
+
|
|
74
235
|
if (typeof(module) != 'undefined') {
|
|
236
|
+
// Play nice with node.js
|
|
75
237
|
module.exports = uuid;
|
|
76
238
|
} else {
|
|
77
|
-
//
|
|
78
|
-
|
|
239
|
+
// Play nice with browsers
|
|
240
|
+
var _previousRoot = _global.uuid;
|
|
241
|
+
|
|
242
|
+
// **`noConflict()` - (browser only) to reset global 'uuid' var**
|
|
243
|
+
uuid.noConflict = function() {
|
|
244
|
+
_global.uuid = _previousRoot;
|
|
245
|
+
return uuid;
|
|
246
|
+
}
|
|
247
|
+
_global.uuid = uuid;
|
|
79
248
|
}
|
|
80
|
-
}
|
|
249
|
+
}());
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
Restler 0.2.
|
|
1
|
+
Restler 0.2.4
|
|
2
2
|
===========
|
|
3
3
|
|
|
4
4
|
(C) Dan Webb (dan@danwebb.net/@danwrong) 2011, Licensed under the MIT-LICENSE
|
|
5
5
|
|
|
6
6
|
An HTTP client library for node.js (0.3 and up). Hides most of the complexity of creating and using http.Client. Very early days yet.
|
|
7
7
|
|
|
8
|
+
See [Version History](https://github.com/danwrong/restler/wiki/Version-History) for changes
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
Features
|
|
10
12
|
--------
|
|
@@ -19,8 +21,9 @@ Features
|
|
|
19
21
|
* Transparently handle SSL (just specify https in the URL)
|
|
20
22
|
* Deals with basic auth for you, just provide username and password options
|
|
21
23
|
* Simple service wrapper that allows you to easily put together REST API libraries
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
* Transparently handle content-encoded responses (gzip, deflate)
|
|
25
|
+
|
|
26
|
+
|
|
24
27
|
API
|
|
25
28
|
---
|
|
26
29
|
|
|
@@ -68,9 +71,12 @@ All of these attempt to turn the response into a JavaScript object. In order to
|
|
|
68
71
|
|
|
69
72
|
* _method_ Request method, can be get, post, put, del
|
|
70
73
|
* _query_ Query string variables as a javascript object, will override the querystring in the URL
|
|
71
|
-
* _data_ The data to be added to the body of the request. Can be a string or any object
|
|
74
|
+
* _data_ The data to be added to the body of the request. Can be a string or any object.
|
|
75
|
+
Note that if you want your request body to be JSON with the Content-Type `application/json`, you need to
|
|
76
|
+
JSON.stringify your object first. Otherwise, it will be sent as `application/x-www-form-urlencoded` and encoded accordingly.
|
|
72
77
|
* _parser_ A function that will be called on the returned data. try parsers.auto, parsers.json etc
|
|
73
78
|
* _encoding_ The encoding of the request body. defaults to utf8
|
|
79
|
+
* _decoding_ The encoding of the response body. For a list of supported values see [Buffers](http://nodejs.org/docs/latest/api/buffers.html#buffers). Additionally accepts `"buffer"` - returns response as `Buffer`. Defaults to `utf8`.
|
|
74
80
|
* _headers_ a hash of HTTP headers to be sent
|
|
75
81
|
* _username_ Basic auth username
|
|
76
82
|
* _password_ Basic auth password
|
|
@@ -82,7 +88,7 @@ All of these attempt to turn the response into a JavaScript object. In order to
|
|
|
82
88
|
Example usage
|
|
83
89
|
-------------
|
|
84
90
|
|
|
85
|
-
var sys = require('
|
|
91
|
+
var sys = require('util'),
|
|
86
92
|
rest = require('./restler');
|
|
87
93
|
|
|
88
94
|
rest.get('http://google.com').on('complete', function(data) {
|
|
@@ -112,7 +118,7 @@ Example usage
|
|
|
112
118
|
password: 'wouldntyouliketoknow',
|
|
113
119
|
data: {
|
|
114
120
|
'sound[message]': 'hello from restler!',
|
|
115
|
-
'sound[file]': rest.file('doug-e-fresh_the-show.mp3', 'audio/mpeg')
|
|
121
|
+
'sound[file]': rest.file('doug-e-fresh_the-show.mp3', null, null, null, 'audio/mpeg')
|
|
116
122
|
}
|
|
117
123
|
}).on('complete', function(data) {
|
|
118
124
|
sys.puts(data.audio_url);
|
|
@@ -135,6 +141,13 @@ Example usage
|
|
|
135
141
|
sys.p(data);
|
|
136
142
|
});
|
|
137
143
|
|
|
144
|
+
// the JSON post
|
|
145
|
+
rest.post('http://example.com/action', {
|
|
146
|
+
data: JSON.stringify({ id: 334 }),
|
|
147
|
+
}).on('complete', function(data, response) {
|
|
148
|
+
// you can get at the raw response like this...
|
|
149
|
+
});
|
|
150
|
+
|
|
138
151
|
|
|
139
152
|
Running the tests
|
|
140
153
|
-----------------
|
|
@@ -144,4 +157,4 @@ Running the tests
|
|
|
144
157
|
TODO
|
|
145
158
|
----
|
|
146
159
|
* Deal with no utf-8 response bodies
|
|
147
|
-
* What do you need? Let me know or fork.
|
|
160
|
+
* What do you need? Let me know or fork.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var fs = require('fs');
|
|
2
|
-
var sys = require(
|
|
2
|
+
var sys = require('util')
|
|
3
3
|
exports.defaultBoundary = '48940923NODERESLTER3890457293';
|
|
4
4
|
|
|
5
5
|
|
|
@@ -109,7 +109,7 @@ Part.prototype = {
|
|
|
109
109
|
fs.open(this.value.path, "r", 0666, function (err, fd) {
|
|
110
110
|
if (err) throw err;
|
|
111
111
|
|
|
112
|
-
position = 0;
|
|
112
|
+
var position = 0;
|
|
113
113
|
|
|
114
114
|
(function reader () {
|
|
115
115
|
fs.read(fd, 1024 * 4, position, "binary", function (er, chunk) {
|
|
@@ -142,12 +142,13 @@ function MultiPartRequest(data, boundary) {
|
|
|
142
142
|
|
|
143
143
|
MultiPartRequest.prototype = {
|
|
144
144
|
_partNames: function() {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
var partNames = [];
|
|
146
|
+
for (var name in this.data) {
|
|
147
|
+
partNames.push(name)
|
|
148
148
|
}
|
|
149
149
|
return partNames;
|
|
150
150
|
},
|
|
151
|
+
|
|
151
152
|
write: function(stream, callback) {
|
|
152
153
|
var partCount = 0, self = this;
|
|
153
154
|
|
|
@@ -157,8 +158,8 @@ MultiPartRequest.prototype = {
|
|
|
157
158
|
|
|
158
159
|
// Let each part write itself out to the stream
|
|
159
160
|
(function writePart() {
|
|
160
|
-
partName =
|
|
161
|
-
part = new Part(partName, self.data[partName], self.boundary);
|
|
161
|
+
var partName = self.partNames[partCount];
|
|
162
|
+
var part = new Part(partName, self.data[partName], self.boundary);
|
|
162
163
|
part.write(stream, function (err) {
|
|
163
164
|
if (err) {
|
|
164
165
|
callback(err);
|
|
@@ -199,4 +200,4 @@ var exportMethods = {
|
|
|
199
200
|
|
|
200
201
|
Object.keys(exportMethods).forEach(function(exportMethod) {
|
|
201
202
|
exports[exportMethod] = exportMethods[exportMethod]
|
|
202
|
-
})
|
|
203
|
+
})
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
var sys = require('
|
|
1
|
+
var sys = require('util'),
|
|
2
2
|
http = require('http'),
|
|
3
3
|
https = require('https'),
|
|
4
4
|
url = require('url'),
|
|
5
5
|
qs = require('querystring'),
|
|
6
|
-
multipart = require('./multipartform')
|
|
6
|
+
multipart = require('./multipartform'),
|
|
7
|
+
zlib = require('zlib');
|
|
7
8
|
|
|
8
9
|
function mixin(target, source) {
|
|
9
10
|
Object.keys(source).forEach(function(key) {
|
|
@@ -20,7 +21,7 @@ function Request(uri, options) {
|
|
|
20
21
|
'Accept': '*/*',
|
|
21
22
|
'User-Agent': 'Restler for node.js',
|
|
22
23
|
'Host': this.url.host
|
|
23
|
-
}
|
|
24
|
+
};
|
|
24
25
|
|
|
25
26
|
mixin(this.headers, options.headers || {});
|
|
26
27
|
|
|
@@ -46,6 +47,11 @@ function Request(uri, options) {
|
|
|
46
47
|
this.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
47
48
|
this.headers['Content-Length'] = this.options.data.length;
|
|
48
49
|
}
|
|
50
|
+
if(typeof this.options.data == 'string') {
|
|
51
|
+
var buffer = new Buffer(this.options.data, this.options.encoding || 'utf8');
|
|
52
|
+
this.options.data = buffer;
|
|
53
|
+
this.headers['Content-Length'] = buffer.length;
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
var proto = (this.url.protocol == 'https:') ? https : http;
|
|
@@ -62,9 +68,10 @@ function Request(uri, options) {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
Request.prototype = new process.EventEmitter();
|
|
71
|
+
|
|
65
72
|
mixin(Request.prototype, {
|
|
66
73
|
_isRedirect: function(response) {
|
|
67
|
-
return ([301, 302].indexOf(response.statusCode) >= 0);
|
|
74
|
+
return ([301, 302, 303].indexOf(response.statusCode) >= 0);
|
|
68
75
|
},
|
|
69
76
|
_fullPath: function() {
|
|
70
77
|
var path = this.url.pathname || '/';
|
|
@@ -101,25 +108,46 @@ mixin(Request.prototype, {
|
|
|
101
108
|
} else {
|
|
102
109
|
var body = '';
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
response.setEncoding('utf8');
|
|
111
|
+
response.setEncoding('binary');
|
|
106
112
|
|
|
107
113
|
response.on('data', function(chunk) {
|
|
108
114
|
body += chunk;
|
|
109
115
|
});
|
|
110
116
|
|
|
111
117
|
response.on('end', function() {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
self._decode(new Buffer(body, 'binary'), response, function(err, body) {
|
|
119
|
+
if (err) {
|
|
120
|
+
self._respond('error', '', 'Failed to decode response body');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
self._encode(body, response, function(body) {
|
|
124
|
+
self._fireEvents(body, response);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
120
127
|
});
|
|
121
128
|
}
|
|
122
129
|
},
|
|
130
|
+
_decode: function(body, response, callback) {
|
|
131
|
+
var encoder = response.headers['content-encoding'];
|
|
132
|
+
if (encoder in decoders) {
|
|
133
|
+
decoders[encoder].call(response, body, callback);
|
|
134
|
+
} else {
|
|
135
|
+
callback(null, body);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
_encode: function(body, response, callback) {
|
|
139
|
+
var self = this;
|
|
140
|
+
if (self.options.decoding == 'buffer') {
|
|
141
|
+
callback(body);
|
|
142
|
+
} else {
|
|
143
|
+
body = body.toString(self.options.decoding);
|
|
144
|
+
if (self.options.parser) {
|
|
145
|
+
self.options.parser.call(response, body, callback);
|
|
146
|
+
} else {
|
|
147
|
+
callback(body);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
123
151
|
_respond: function(type, data, response) {
|
|
124
152
|
if (this.options.originalRequest) {
|
|
125
153
|
this.options.originalRequest.emit(type, data, response);
|
|
@@ -135,11 +163,11 @@ mixin(Request.prototype, {
|
|
|
135
163
|
this._respond(response.statusCode.toString(), body, response);
|
|
136
164
|
this._respond('complete', body, response);
|
|
137
165
|
},
|
|
138
|
-
_makeRequest: function() {
|
|
166
|
+
_makeRequest: function() {
|
|
139
167
|
var self = this;
|
|
140
168
|
|
|
141
169
|
this.request.on('response', function(response) {
|
|
142
|
-
|
|
170
|
+
self._responseHandler(response);
|
|
143
171
|
}).on('error', function(err) {
|
|
144
172
|
self._respond('error', null, err);
|
|
145
173
|
});
|
|
@@ -155,7 +183,7 @@ mixin(Request.prototype, {
|
|
|
155
183
|
if (this.options.data) {
|
|
156
184
|
this.request.write(this.options.data.toString(), this.options.encoding || 'utf8');
|
|
157
185
|
}
|
|
158
|
-
|
|
186
|
+
this.request.end();
|
|
159
187
|
}
|
|
160
188
|
|
|
161
189
|
return this;
|
|
@@ -170,7 +198,9 @@ function shortcutOptions(options, method) {
|
|
|
170
198
|
}
|
|
171
199
|
|
|
172
200
|
function request(url, options) {
|
|
173
|
-
|
|
201
|
+
var request = new Request(url, options);
|
|
202
|
+
request.on('error', function() {});
|
|
203
|
+
return request.run();
|
|
174
204
|
}
|
|
175
205
|
|
|
176
206
|
function get(url, options) {
|
|
@@ -207,7 +237,7 @@ var parsers = {
|
|
|
207
237
|
json: function(data, callback) {
|
|
208
238
|
callback(data && JSON.parse(data));
|
|
209
239
|
}
|
|
210
|
-
}
|
|
240
|
+
};
|
|
211
241
|
|
|
212
242
|
parsers.auto.matchers = {
|
|
213
243
|
'application/json': parsers.json
|
|
@@ -233,15 +263,27 @@ try {
|
|
|
233
263
|
parser.on('end', function(result) {
|
|
234
264
|
callback(result);
|
|
235
265
|
});
|
|
236
|
-
|
|
237
|
-
|
|
266
|
+
try {
|
|
267
|
+
parser.parseString(data);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
callback({error:'Oops, something went wrong.'});
|
|
270
|
+
}
|
|
238
271
|
} else {
|
|
239
272
|
callback();
|
|
240
273
|
}
|
|
241
274
|
};
|
|
242
275
|
|
|
243
276
|
parsers.auto.matchers['application/xml'] = parsers.xml;
|
|
244
|
-
} catch(e) {}
|
|
277
|
+
} catch(e) { }
|
|
278
|
+
|
|
279
|
+
var decoders = {
|
|
280
|
+
gzip: function(buf, callback) {
|
|
281
|
+
zlib.gunzip(buf, callback);
|
|
282
|
+
},
|
|
283
|
+
deflate: function(buf, callback) {
|
|
284
|
+
zlib.inflate(buf, callback);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
245
287
|
|
|
246
288
|
|
|
247
289
|
function Service(defaults) {
|