vulcan 0.6.1 → 0.7.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 +20 -10
- data/lib/vulcan/version.rb +1 -1
- data/server/Procfile +1 -1
- data/server/bin/web +10 -0
- data/server/lib/cloudant.coffee +20 -0
- data/server/lib/logger.coffee +17 -0
- data/server/lib/on.coffee +10 -0
- data/server/lib/spawner.coffee +65 -0
- data/server/node_modules/coffee-script/CNAME +1 -0
- data/server/node_modules/coffee-script/LICENSE +22 -0
- data/server/node_modules/coffee-script/README +51 -0
- data/server/node_modules/coffee-script/Rakefile +78 -0
- data/server/node_modules/coffee-script/bin/cake +7 -0
- data/server/node_modules/coffee-script/bin/coffee +7 -0
- data/server/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/server/node_modules/coffee-script/lib/coffee-script/browser.js +92 -0
- data/server/node_modules/coffee-script/lib/coffee-script/cake.js +111 -0
- data/server/node_modules/coffee-script/lib/coffee-script/coffee-script.js +167 -0
- data/server/node_modules/coffee-script/lib/coffee-script/command.js +500 -0
- data/server/node_modules/coffee-script/lib/coffee-script/grammar.js +606 -0
- data/server/node_modules/coffee-script/lib/coffee-script/helpers.js +77 -0
- data/server/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/server/node_modules/coffee-script/lib/coffee-script/lexer.js +788 -0
- data/server/node_modules/coffee-script/lib/coffee-script/nodes.js +2986 -0
- data/server/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
- data/server/node_modules/coffee-script/lib/coffee-script/parser.js +683 -0
- data/server/node_modules/coffee-script/lib/coffee-script/repl.js +261 -0
- data/server/node_modules/coffee-script/lib/coffee-script/rewriter.js +349 -0
- data/server/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/server/node_modules/coffee-script/package.json +55 -0
- data/server/node_modules/connect-form/History.md +0 -6
- data/server/node_modules/connect-form/lib/connect-form.js +2 -4
- data/server/node_modules/connect-form/node_modules/formidable/Readme.md +64 -36
- data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +5 -1
- data/server/node_modules/connect-form/node_modules/formidable/package.json +20 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/common.js +5 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +1 -1
- data/server/node_modules/connect-form/node_modules/formidable/test/{slow → integration}/test-fixtures.js +38 -33
- data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/run.js +1 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
- data/server/node_modules/connect-form/package.json +27 -5
- data/server/node_modules/cradle/README.md +10 -10
- data/server/node_modules/cradle/lib/cradle.js +117 -523
- data/server/node_modules/cradle/lib/cradle/database/attachments.js +120 -0
- data/server/node_modules/cradle/lib/cradle/database/changes.js +56 -0
- data/server/node_modules/cradle/lib/cradle/database/documents.js +215 -0
- data/server/node_modules/cradle/lib/cradle/database/index.js +65 -0
- data/server/node_modules/cradle/lib/cradle/database/views.js +125 -0
- data/server/node_modules/cradle/node_modules/follow/LICENSE +202 -0
- data/server/node_modules/cradle/node_modules/follow/README.md +164 -0
- data/server/node_modules/cradle/node_modules/follow/Rakefile +54 -0
- data/server/node_modules/cradle/node_modules/follow/api.js +35 -0
- data/server/node_modules/cradle/node_modules/follow/browser/eventemitter2.js +453 -0
- data/server/node_modules/cradle/node_modules/follow/browser/export.js +78 -0
- data/server/node_modules/cradle/node_modules/follow/browser/index.html +14 -0
- data/server/node_modules/cradle/node_modules/follow/browser/jquery-1.6.1.min.js +18 -0
- data/server/node_modules/cradle/node_modules/follow/browser/log4js.js +46 -0
- data/server/node_modules/cradle/node_modules/follow/browser/main.js +92 -0
- data/server/node_modules/cradle/node_modules/follow/browser/querystring.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/browser/request.jquery.js +237 -0
- data/server/node_modules/cradle/node_modules/follow/browser/require.js +33 -0
- data/server/node_modules/cradle/node_modules/follow/browser/util.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/cli.js +101 -0
- data/server/node_modules/cradle/node_modules/follow/lib/feed.js +556 -0
- data/server/node_modules/cradle/node_modules/follow/lib/index.js +66 -0
- data/server/node_modules/cradle/node_modules/follow/lib/stream.js +305 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/README.md +285 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/main.js +618 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/mimetypes.js +146 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/run.sh +6 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/server.js +57 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-body.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-errors.js +30 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-oauth.js +109 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-pipes.js +167 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/index.js +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/follow/package.json +45 -0
- data/server/node_modules/cradle/node_modules/follow/test/couch.js +153 -0
- data/server/node_modules/cradle/node_modules/follow/test/follow.js +136 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues.js +178 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues/10.js +24 -0
- data/server/node_modules/cradle/node_modules/follow/test/stream.js +493 -0
- data/server/node_modules/cradle/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/request/README.md +287 -0
- data/server/node_modules/cradle/node_modules/request/forever.js +103 -0
- data/server/node_modules/cradle/node_modules/request/main.js +913 -0
- data/server/node_modules/cradle/node_modules/request/mimetypes.js +152 -0
- data/server/node_modules/cradle/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/run.js +38 -0
- data/server/node_modules/cradle/node_modules/request/tests/server.js +82 -0
- data/server/node_modules/cradle/node_modules/request/tests/squid.conf +77 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.cnf +20 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crl +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crt +17 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.csr +13 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.key +18 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.srl +1 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.cnf +19 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.csr +11 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.key +9 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/npm-ca.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.crt +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.key +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-body.js +95 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-defaults.js +68 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-errors.js +37 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-headers.js +52 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-httpModule.js +94 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https-strict.js +97 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https.js +86 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-oauth.js +117 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-params.js +92 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-pipes.js +202 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-qs.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-redirect.js +154 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-toJSON.js +14 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-tunnel.js +61 -0
- data/server/node_modules/cradle/node_modules/request/tunnel.js +229 -0
- data/server/node_modules/cradle/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/index.js +65 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/vargs/package.json +33 -10
- data/server/node_modules/cradle/package.json +50 -12
- data/server/node_modules/cradle/test/cache-test.js +1 -4
- data/server/node_modules/cradle/test/connection-test.js +179 -0
- data/server/node_modules/cradle/test/database-attachment-test.js +344 -0
- data/server/node_modules/cradle/test/database-cache-test.js +132 -0
- data/server/node_modules/cradle/test/database-test.js +219 -0
- data/server/node_modules/cradle/test/database-view-test.js +141 -0
- data/server/node_modules/cradle/test/fixtures/databases.json +28 -1
- data/server/node_modules/cradle/test/helpers/seed.js +14 -5
- data/server/node_modules/cradle/test/response-test.js +1 -1
- data/server/node_modules/express/History.md +16 -0
- data/server/node_modules/express/bin/express +7 -6
- data/server/node_modules/express/lib-cov/application.js +510 -0
- data/server/node_modules/express/lib-cov/express.js +65 -0
- data/server/node_modules/express/lib-cov/middleware.js +54 -0
- data/server/node_modules/express/lib-cov/request.js +225 -0
- data/server/node_modules/express/lib-cov/response.js +611 -0
- data/server/node_modules/express/lib-cov/router/collection.js +40 -0
- data/server/node_modules/express/lib-cov/router/index.js +515 -0
- data/server/node_modules/express/lib-cov/router/methods.js +9 -0
- data/server/node_modules/express/lib-cov/router/route.js +68 -0
- data/server/node_modules/express/lib-cov/utils.js +151 -0
- data/server/node_modules/express/lib-cov/view.js +81 -0
- data/server/node_modules/express/lib/express.js +1 -1
- data/server/node_modules/express/lib/http.js +1 -2
- data/server/node_modules/express/lib/request.js +2 -2
- data/server/node_modules/express/lib/router/methods.js +10 -1
- data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/http.js +3 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +0 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +1 -2
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +42 -25
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +14 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/express/node_modules/connect/package.json +35 -7
- data/server/node_modules/express/node_modules/mime/package.json +30 -8
- data/server/node_modules/express/node_modules/mkdirp/README.markdown +35 -2
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +1 -1
- data/server/node_modules/express/node_modules/mkdirp/index.js +72 -13
- data/server/node_modules/express/node_modules/mkdirp/package.json +39 -21
- data/server/node_modules/express/node_modules/mkdirp/test/chmod.js +38 -0
- data/server/node_modules/express/node_modules/mkdirp/test/clobber.js +37 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm.js +32 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/server/node_modules/express/node_modules/mkdirp/test/sync.js +27 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask.js +28 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask_sync.js +27 -0
- data/server/node_modules/express/node_modules/qs/History.md +10 -0
- data/server/node_modules/express/node_modules/qs/Readme.md +9 -2
- data/server/node_modules/express/node_modules/qs/examples.js +3 -0
- data/server/node_modules/express/node_modules/qs/lib/querystring.js +8 -6
- data/server/node_modules/express/node_modules/qs/package.json +26 -8
- data/server/node_modules/express/node_modules/qs/test/parse.js +13 -1
- data/server/node_modules/express/node_modules/qs/test/stringify.js +45 -37
- data/server/node_modules/express/package.json +55 -16
- data/server/node_modules/express/test.js +41 -0
- data/server/node_modules/knox/package.json +26 -4
- data/server/node_modules/node-uuid/package.json +40 -11
- data/server/node_modules/node-uuid/test/test.js +1 -1
- data/server/node_modules/nodemon/README.md +120 -0
- data/server/node_modules/nodemon/nodemon.js +518 -0
- data/server/node_modules/nodemon/nodemonignore.example +11 -0
- data/server/node_modules/nodemon/package.json +49 -0
- data/server/node_modules/restler/README.md +144 -94
- data/server/node_modules/restler/lib/multipartform.js +2 -0
- data/server/node_modules/restler/lib/restler.js +218 -61
- data/server/node_modules/restler/package.json +35 -8
- data/server/node_modules/restler/test/all.js +6 -1
- data/server/node_modules/restler/test/restler.js +624 -118
- data/server/package.json +14 -10
- data/server/web.coffee +64 -0
- data/server/web.js +15 -3
- metadata +170 -57
- data/server/index.js +0 -14
- data/server/node_modules/connect-form/LICENSE +0 -22
- data/server/node_modules/connect-form/index.js +0 -100
- data/server/node_modules/connect-form/node_modules/formidable/test/fast/test-incoming-form.js +0 -45
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/cradle/Makefile +0 -10
- data/server/node_modules/cradle/test/cradle-test.js +0 -650
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- 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/test.js +0 -52
- data/server/node_modules/express/testing/foo/app.js +0 -35
- data/server/node_modules/express/testing/foo/package.json +0 -9
- data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
- data/server/node_modules/express/testing/foo/routes/index.js +0 -10
- data/server/node_modules/express/testing/foo/views/index.jade +0 -2
- data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
- data/server/node_modules/express/testing/index.js +0 -43
- data/server/node_modules/express/testing/public/test.txt +0 -2971
- data/server/node_modules/express/testing/views/page.html +0 -1
- data/server/node_modules/express/testing/views/page.jade +0 -3
- data/server/node_modules/express/testing/views/test.md +0 -1
- data/server/node_modules/express/testing/views/user/index.jade +0 -1
- data/server/node_modules/express/testing/views/user/list.jade +0 -1
- data/server/node_modules/knox/lib/knox/mime/index.js +0 -308
- data/server/node_modules/knox/lib/knox/mime/test.js +0 -59
- data/server/node_modules/node-uuid/test/benchmark-native +0 -0
- data/server/node_modules/on/index.js +0 -13
- data/server/node_modules/restler/test/test_helper.js +0 -163
- data/server/node_modules/spawner/index.js +0 -106
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var server = require('./server')
|
|
2
|
+
, assert = require('assert')
|
|
3
|
+
, request = require('../main.js')
|
|
4
|
+
;
|
|
5
|
+
|
|
6
|
+
var s = server.createServer();
|
|
7
|
+
|
|
8
|
+
var tests =
|
|
9
|
+
{ testGet :
|
|
10
|
+
{ resp : server.createGetResponse("TESTING!")
|
|
11
|
+
, expectBody: "TESTING!"
|
|
12
|
+
}
|
|
13
|
+
, testGetChunkBreak :
|
|
14
|
+
{ resp : server.createChunkResponse(
|
|
15
|
+
[ new Buffer([239])
|
|
16
|
+
, new Buffer([163])
|
|
17
|
+
, new Buffer([191])
|
|
18
|
+
, new Buffer([206])
|
|
19
|
+
, new Buffer([169])
|
|
20
|
+
, new Buffer([226])
|
|
21
|
+
, new Buffer([152])
|
|
22
|
+
, new Buffer([131])
|
|
23
|
+
])
|
|
24
|
+
, expectBody: "Ω☃"
|
|
25
|
+
}
|
|
26
|
+
, testGetBuffer :
|
|
27
|
+
{ resp : server.createGetResponse(new Buffer("TESTING!"))
|
|
28
|
+
, encoding: null
|
|
29
|
+
, expectBody: new Buffer("TESTING!")
|
|
30
|
+
}
|
|
31
|
+
, testGetJSON :
|
|
32
|
+
{ resp : server.createGetResponse('{"test":true}', 'application/json')
|
|
33
|
+
, json : true
|
|
34
|
+
, expectBody: {"test":true}
|
|
35
|
+
}
|
|
36
|
+
, testPutString :
|
|
37
|
+
{ resp : server.createPostValidator("PUTTINGDATA")
|
|
38
|
+
, method : "PUT"
|
|
39
|
+
, body : "PUTTINGDATA"
|
|
40
|
+
}
|
|
41
|
+
, testPutBuffer :
|
|
42
|
+
{ resp : server.createPostValidator("PUTTINGDATA")
|
|
43
|
+
, method : "PUT"
|
|
44
|
+
, body : new Buffer("PUTTINGDATA")
|
|
45
|
+
}
|
|
46
|
+
, testPutJSON :
|
|
47
|
+
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
|
|
48
|
+
, method: "PUT"
|
|
49
|
+
, json: {foo: 'bar'}
|
|
50
|
+
}
|
|
51
|
+
, testPutMultipart :
|
|
52
|
+
{ resp: server.createPostValidator(
|
|
53
|
+
'--frontier\r\n' +
|
|
54
|
+
'content-type: text/html\r\n' +
|
|
55
|
+
'\r\n' +
|
|
56
|
+
'<html><body>Oh hi.</body></html>' +
|
|
57
|
+
'\r\n--frontier\r\n\r\n' +
|
|
58
|
+
'Oh hi.' +
|
|
59
|
+
'\r\n--frontier--'
|
|
60
|
+
)
|
|
61
|
+
, method: "PUT"
|
|
62
|
+
, multipart:
|
|
63
|
+
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
|
|
64
|
+
, {'body': 'Oh hi.'}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
s.listen(s.port, function () {
|
|
70
|
+
|
|
71
|
+
var counter = 0
|
|
72
|
+
|
|
73
|
+
for (i in tests) {
|
|
74
|
+
(function () {
|
|
75
|
+
var test = tests[i]
|
|
76
|
+
s.on('/'+i, test.resp)
|
|
77
|
+
//test.uri = s.url + '/' + i
|
|
78
|
+
request(s.url + '/' + i, test, function (err, resp, body) {
|
|
79
|
+
if (err) throw err
|
|
80
|
+
if (test.expectBody) {
|
|
81
|
+
assert.deepEqual(test.expectBody, body)
|
|
82
|
+
}
|
|
83
|
+
counter = counter - 1;
|
|
84
|
+
if (counter === 0) {
|
|
85
|
+
console.log(Object.keys(tests).length+" tests passed.")
|
|
86
|
+
s.close()
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
counter++
|
|
90
|
+
})()
|
|
91
|
+
}
|
|
92
|
+
})
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
var server = require('./server')
|
|
2
|
+
, events = require('events')
|
|
3
|
+
, stream = require('stream')
|
|
4
|
+
, assert = require('assert')
|
|
5
|
+
, fs = require('fs')
|
|
6
|
+
, request = require('../main.js')
|
|
7
|
+
, path = require('path')
|
|
8
|
+
, util = require('util')
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
var s = server.createServer(3453);
|
|
12
|
+
|
|
13
|
+
function ValidationStream(str) {
|
|
14
|
+
this.str = str
|
|
15
|
+
this.buf = ''
|
|
16
|
+
this.on('data', function (data) {
|
|
17
|
+
this.buf += data
|
|
18
|
+
})
|
|
19
|
+
this.on('end', function () {
|
|
20
|
+
assert.equal(this.str, this.buf)
|
|
21
|
+
})
|
|
22
|
+
this.writable = true
|
|
23
|
+
}
|
|
24
|
+
util.inherits(ValidationStream, stream.Stream)
|
|
25
|
+
ValidationStream.prototype.write = function (chunk) {
|
|
26
|
+
this.emit('data', chunk)
|
|
27
|
+
}
|
|
28
|
+
ValidationStream.prototype.end = function (chunk) {
|
|
29
|
+
if (chunk) emit('data', chunk)
|
|
30
|
+
this.emit('end')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
s.listen(s.port, function () {
|
|
34
|
+
counter = 0;
|
|
35
|
+
|
|
36
|
+
var check = function () {
|
|
37
|
+
counter = counter - 1
|
|
38
|
+
if (counter === 0) {
|
|
39
|
+
console.log('All tests passed.')
|
|
40
|
+
setTimeout(function () {
|
|
41
|
+
process.exit();
|
|
42
|
+
}, 500)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Test pipeing to a request object
|
|
47
|
+
s.once('/push', server.createPostValidator("mydata"));
|
|
48
|
+
|
|
49
|
+
var mydata = new stream.Stream();
|
|
50
|
+
mydata.readable = true
|
|
51
|
+
|
|
52
|
+
counter++
|
|
53
|
+
var r1 = request.put({url:'http://localhost:3453/push'}, function () {
|
|
54
|
+
check();
|
|
55
|
+
})
|
|
56
|
+
mydata.pipe(r1)
|
|
57
|
+
|
|
58
|
+
mydata.emit('data', 'mydata');
|
|
59
|
+
mydata.emit('end');
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
// Test pipeing from a request object.
|
|
63
|
+
s.once('/pull', server.createGetResponse("mypulldata"));
|
|
64
|
+
|
|
65
|
+
var mypulldata = new stream.Stream();
|
|
66
|
+
mypulldata.writable = true
|
|
67
|
+
|
|
68
|
+
counter++
|
|
69
|
+
request({url:'http://localhost:3453/pull'}).pipe(mypulldata)
|
|
70
|
+
|
|
71
|
+
var d = '';
|
|
72
|
+
|
|
73
|
+
mypulldata.write = function (chunk) {
|
|
74
|
+
d += chunk;
|
|
75
|
+
}
|
|
76
|
+
mypulldata.end = function () {
|
|
77
|
+
assert.equal(d, 'mypulldata');
|
|
78
|
+
check();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
s.on('/cat', function (req, resp) {
|
|
83
|
+
if (req.method === "GET") {
|
|
84
|
+
resp.writeHead(200, {'content-type':'text/plain-test', 'content-length':4});
|
|
85
|
+
resp.end('asdf')
|
|
86
|
+
} else if (req.method === "PUT") {
|
|
87
|
+
assert.equal(req.headers['content-type'], 'text/plain-test');
|
|
88
|
+
assert.equal(req.headers['content-length'], 4)
|
|
89
|
+
var validate = '';
|
|
90
|
+
|
|
91
|
+
req.on('data', function (chunk) {validate += chunk})
|
|
92
|
+
req.on('end', function () {
|
|
93
|
+
resp.writeHead(201);
|
|
94
|
+
resp.end();
|
|
95
|
+
assert.equal(validate, 'asdf');
|
|
96
|
+
check();
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
s.on('/pushjs', function (req, resp) {
|
|
101
|
+
if (req.method === "PUT") {
|
|
102
|
+
assert.equal(req.headers['content-type'], 'text/javascript');
|
|
103
|
+
check();
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
s.on('/catresp', function (req, resp) {
|
|
107
|
+
request.get('http://localhost:3453/cat').pipe(resp)
|
|
108
|
+
})
|
|
109
|
+
s.on('/doodle', function (req, resp) {
|
|
110
|
+
if (req.headers['x-oneline-proxy']) {
|
|
111
|
+
resp.setHeader('x-oneline-proxy', 'yup')
|
|
112
|
+
}
|
|
113
|
+
resp.writeHead('200', {'content-type':'image/png'})
|
|
114
|
+
fs.createReadStream(path.join(__dirname, 'googledoodle.png')).pipe(resp)
|
|
115
|
+
})
|
|
116
|
+
s.on('/onelineproxy', function (req, resp) {
|
|
117
|
+
var x = request('http://localhost:3453/doodle')
|
|
118
|
+
req.pipe(x)
|
|
119
|
+
x.pipe(resp)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
counter++
|
|
123
|
+
fs.createReadStream(__filename).pipe(request.put('http://localhost:3453/pushjs'))
|
|
124
|
+
|
|
125
|
+
counter++
|
|
126
|
+
request.get('http://localhost:3453/cat').pipe(request.put('http://localhost:3453/cat'))
|
|
127
|
+
|
|
128
|
+
counter++
|
|
129
|
+
request.get('http://localhost:3453/catresp', function (e, resp, body) {
|
|
130
|
+
assert.equal(resp.headers['content-type'], 'text/plain-test');
|
|
131
|
+
assert.equal(resp.headers['content-length'], 4)
|
|
132
|
+
check();
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
var doodleWrite = fs.createWriteStream(path.join(__dirname, 'test.png'))
|
|
136
|
+
|
|
137
|
+
counter++
|
|
138
|
+
request.get('http://localhost:3453/doodle').pipe(doodleWrite)
|
|
139
|
+
|
|
140
|
+
doodleWrite.on('close', function () {
|
|
141
|
+
assert.deepEqual(fs.readFileSync(path.join(__dirname, 'googledoodle.png')), fs.readFileSync(path.join(__dirname, 'test.png')))
|
|
142
|
+
check()
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
process.on('exit', function () {
|
|
146
|
+
fs.unlinkSync(path.join(__dirname, 'test.png'))
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
counter++
|
|
150
|
+
request.get({uri:'http://localhost:3453/onelineproxy', headers:{'x-oneline-proxy':'nope'}}, function (err, resp, body) {
|
|
151
|
+
assert.equal(resp.headers['x-oneline-proxy'], 'yup')
|
|
152
|
+
check()
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
s.on('/afterresponse', function (req, resp) {
|
|
156
|
+
resp.write('d')
|
|
157
|
+
resp.end()
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
counter++
|
|
161
|
+
var afterresp = request.post('http://localhost:3453/afterresponse').on('response', function () {
|
|
162
|
+
var v = new ValidationStream('d')
|
|
163
|
+
afterresp.pipe(v)
|
|
164
|
+
v.on('end', check)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
s.on('/forward1', function (req, resp) {
|
|
168
|
+
resp.writeHead(302, {location:'/forward2'})
|
|
169
|
+
resp.end()
|
|
170
|
+
})
|
|
171
|
+
s.on('/forward2', function (req, resp) {
|
|
172
|
+
resp.writeHead('200', {'content-type':'image/png'})
|
|
173
|
+
resp.write('d')
|
|
174
|
+
resp.end()
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
counter++
|
|
178
|
+
var validateForward = new ValidationStream('d')
|
|
179
|
+
validateForward.on('end', check)
|
|
180
|
+
request.get('http://localhost:3453/forward1').pipe(validateForward)
|
|
181
|
+
|
|
182
|
+
// Test pipe options
|
|
183
|
+
s.once('/opts', server.createGetResponse('opts response'));
|
|
184
|
+
|
|
185
|
+
var optsStream = new stream.Stream();
|
|
186
|
+
optsStream.writable = true
|
|
187
|
+
|
|
188
|
+
var optsData = '';
|
|
189
|
+
optsStream.write = function (buf) {
|
|
190
|
+
optsData += buf;
|
|
191
|
+
if (optsData === 'opts response') {
|
|
192
|
+
setTimeout(check, 10);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
optsStream.end = function () {
|
|
197
|
+
assert.fail('end called')
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
counter++
|
|
201
|
+
request({url:'http://localhost:3453/opts'}).pipe(optsStream, { end : false })
|
|
202
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var server = require('./server')
|
|
2
|
+
, events = require('events')
|
|
3
|
+
, stream = require('stream')
|
|
4
|
+
, assert = require('assert')
|
|
5
|
+
, fs = require('fs')
|
|
6
|
+
, request = require('../main.js')
|
|
7
|
+
, path = require('path')
|
|
8
|
+
, util = require('util')
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
var port = 6768
|
|
12
|
+
, called = false
|
|
13
|
+
, proxiedHost = 'google.com'
|
|
14
|
+
;
|
|
15
|
+
|
|
16
|
+
var s = server.createServer(port)
|
|
17
|
+
s.listen(port, function () {
|
|
18
|
+
s.on('http://google.com/', function (req, res) {
|
|
19
|
+
called = true
|
|
20
|
+
assert.equal(req.headers.host, proxiedHost)
|
|
21
|
+
res.writeHeader(200)
|
|
22
|
+
res.end()
|
|
23
|
+
})
|
|
24
|
+
request ({
|
|
25
|
+
url: 'http://'+proxiedHost,
|
|
26
|
+
proxy: 'http://localhost:'+port
|
|
27
|
+
/*
|
|
28
|
+
//should behave as if these arguments where passed:
|
|
29
|
+
url: 'http://localhost:'+port,
|
|
30
|
+
headers: {host: proxiedHost}
|
|
31
|
+
//*/
|
|
32
|
+
}, function (err, res, body) {
|
|
33
|
+
s.close()
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
process.on('exit', function () {
|
|
38
|
+
assert.ok(called, 'the request must be made to the proxy server')
|
|
39
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var request = request = require('../main.js')
|
|
2
|
+
, assert = require('assert')
|
|
3
|
+
;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// Test adding a querystring
|
|
7
|
+
var req1 = request.get({ uri: 'http://www.google.com', qs: { q : 'search' }})
|
|
8
|
+
setTimeout(function() {
|
|
9
|
+
assert.equal('/?q=search', req1.path)
|
|
10
|
+
}, 1)
|
|
11
|
+
|
|
12
|
+
// Test replacing a querystring value
|
|
13
|
+
var req2 = request.get({ uri: 'http://www.google.com?q=abc', qs: { q : 'search' }})
|
|
14
|
+
setTimeout(function() {
|
|
15
|
+
assert.equal('/?q=search', req2.path)
|
|
16
|
+
}, 1)
|
|
17
|
+
|
|
18
|
+
// Test appending a querystring value to the ones present in the uri
|
|
19
|
+
var req3 = request.get({ uri: 'http://www.google.com?x=y', qs: { q : 'search' }})
|
|
20
|
+
setTimeout(function() {
|
|
21
|
+
assert.equal('/?x=y&q=search', req3.path)
|
|
22
|
+
}, 1)
|
|
23
|
+
|
|
24
|
+
// Test leaving a querystring alone
|
|
25
|
+
var req4 = request.get({ uri: 'http://www.google.com?x=y'})
|
|
26
|
+
setTimeout(function() {
|
|
27
|
+
assert.equal('/?x=y', req4.path)
|
|
28
|
+
}, 1)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var server = require('./server')
|
|
2
|
+
, assert = require('assert')
|
|
3
|
+
, request = require('../main.js')
|
|
4
|
+
, Cookie = require('../vendor/cookie')
|
|
5
|
+
, Jar = require('../vendor/cookie/jar')
|
|
6
|
+
|
|
7
|
+
var s = server.createServer()
|
|
8
|
+
|
|
9
|
+
s.listen(s.port, function () {
|
|
10
|
+
var server = 'http://localhost:' + s.port;
|
|
11
|
+
var hits = {}
|
|
12
|
+
var passed = 0;
|
|
13
|
+
|
|
14
|
+
bouncer(301, 'temp')
|
|
15
|
+
bouncer(302, 'perm')
|
|
16
|
+
bouncer(302, 'nope')
|
|
17
|
+
|
|
18
|
+
function bouncer(code, label) {
|
|
19
|
+
var landing = label+'_landing';
|
|
20
|
+
|
|
21
|
+
s.on('/'+label, function (req, res) {
|
|
22
|
+
hits[label] = true;
|
|
23
|
+
res.writeHead(code, {
|
|
24
|
+
'location':server + '/'+landing,
|
|
25
|
+
'set-cookie': 'ham=eggs'
|
|
26
|
+
})
|
|
27
|
+
res.end()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
s.on('/'+landing, function (req, res) {
|
|
31
|
+
if (req.method !== 'GET') { // We should only accept GET redirects
|
|
32
|
+
console.error("Got a non-GET request to the redirect destination URL");
|
|
33
|
+
res.writeHead(400);
|
|
34
|
+
res.end();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Make sure the cookie doesn't get included twice, see #139:
|
|
38
|
+
// Make sure cookies are set properly after redirect
|
|
39
|
+
assert.equal(req.headers.cookie, 'foo=bar; quux=baz; ham=eggs');
|
|
40
|
+
hits[landing] = true;
|
|
41
|
+
res.writeHead(200)
|
|
42
|
+
res.end(landing)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Permanent bounce
|
|
47
|
+
var jar = new Jar()
|
|
48
|
+
jar.add(new Cookie('quux=baz'))
|
|
49
|
+
request({uri: server+'/perm', jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
50
|
+
if (er) throw er
|
|
51
|
+
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
|
|
52
|
+
assert.ok(hits.perm, 'Original request is to /perm')
|
|
53
|
+
assert.ok(hits.perm_landing, 'Forward to permanent landing URL')
|
|
54
|
+
assert.equal(body, 'perm_landing', 'Got permanent landing content')
|
|
55
|
+
passed += 1
|
|
56
|
+
done()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// Temporary bounce
|
|
60
|
+
request({uri: server+'/temp', jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
61
|
+
if (er) throw er
|
|
62
|
+
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
|
|
63
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
64
|
+
assert.ok(hits.temp_landing, 'Forward to temporary landing URL')
|
|
65
|
+
assert.equal(body, 'temp_landing', 'Got temporary landing content')
|
|
66
|
+
passed += 1
|
|
67
|
+
done()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Prevent bouncing.
|
|
71
|
+
request({uri:server+'/nope', jar: jar, headers: {cookie: 'foo=bar'}, followRedirect:false}, function (er, res, body) {
|
|
72
|
+
if (er) throw er
|
|
73
|
+
if (res.statusCode !== 302) throw new Error('Status is not 302: '+res.statusCode)
|
|
74
|
+
assert.ok(hits.nope, 'Original request to /nope')
|
|
75
|
+
assert.ok(!hits.nope_landing, 'No chasing the redirect')
|
|
76
|
+
assert.equal(res.statusCode, 302, 'Response is the bounce itself')
|
|
77
|
+
passed += 1
|
|
78
|
+
done()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// Should not follow post redirects by default
|
|
82
|
+
request.post(server+'/temp', { jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
83
|
+
if (er) throw er
|
|
84
|
+
if (res.statusCode !== 301) throw new Error('Status is not 301: '+res.statusCode)
|
|
85
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
86
|
+
assert.ok(!hits.temp_landing, 'No chasing the redirect when post')
|
|
87
|
+
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
|
|
88
|
+
passed += 1
|
|
89
|
+
done()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// Should follow post redirects when followAllRedirects true
|
|
93
|
+
request.post({uri:server+'/temp', followAllRedirects:true, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
94
|
+
if (er) throw er
|
|
95
|
+
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
|
|
96
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
97
|
+
assert.ok(hits.temp_landing, 'Forward to temporary landing URL')
|
|
98
|
+
assert.equal(body, 'temp_landing', 'Got temporary landing content')
|
|
99
|
+
passed += 1
|
|
100
|
+
done()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
request.post({uri:server+'/temp', followAllRedirects:false, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
104
|
+
if (er) throw er
|
|
105
|
+
if (res.statusCode !== 301) throw new Error('Status is not 301: '+res.statusCode)
|
|
106
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
107
|
+
assert.ok(!hits.temp_landing, 'No chasing the redirect')
|
|
108
|
+
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
|
|
109
|
+
passed += 1
|
|
110
|
+
done()
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// Should not follow delete redirects by default
|
|
114
|
+
request.del(server+'/temp', { jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
115
|
+
if (er) throw er
|
|
116
|
+
if (res.statusCode < 301) throw new Error('Status is not a redirect.')
|
|
117
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
118
|
+
assert.ok(!hits.temp_landing, 'No chasing the redirect when delete')
|
|
119
|
+
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
|
|
120
|
+
passed += 1
|
|
121
|
+
done()
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// Should not follow delete redirects even if followRedirect is set to true
|
|
125
|
+
request.del(server+'/temp', { followRedirect: true, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
126
|
+
if (er) throw er
|
|
127
|
+
if (res.statusCode !== 301) throw new Error('Status is not 301: '+res.statusCode)
|
|
128
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
129
|
+
assert.ok(!hits.temp_landing, 'No chasing the redirect when delete')
|
|
130
|
+
assert.equal(res.statusCode, 301, 'Response is the bounce itself')
|
|
131
|
+
passed += 1
|
|
132
|
+
done()
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
// Should follow delete redirects when followAllRedirects true
|
|
136
|
+
request.del(server+'/temp', {followAllRedirects:true, jar: jar, headers: {cookie: 'foo=bar'}}, function (er, res, body) {
|
|
137
|
+
if (er) throw er
|
|
138
|
+
if (res.statusCode !== 200) throw new Error('Status is not 200: '+res.statusCode)
|
|
139
|
+
assert.ok(hits.temp, 'Original request is to /temp')
|
|
140
|
+
assert.ok(hits.temp_landing, 'Forward to temporary landing URL')
|
|
141
|
+
assert.equal(body, 'temp_landing', 'Got temporary landing content')
|
|
142
|
+
passed += 1
|
|
143
|
+
done()
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
var reqs_done = 0;
|
|
147
|
+
function done() {
|
|
148
|
+
reqs_done += 1;
|
|
149
|
+
if(reqs_done == 9) {
|
|
150
|
+
console.log(passed + ' tests passed.')
|
|
151
|
+
s.close()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
})
|