traceur-rb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +2 -2
- data/lib/js/compile.js +7 -15
- data/lib/traceur.rb +2 -1
- data/lib/traceur/compilation_error.rb +27 -0
- data/lib/traceur/compiler.rb +4 -1
- data/lib/traceur/configuration.rb +1 -1
- data/lib/traceur/node/runner.rb +1 -1
- data/lib/traceur/version.rb +1 -1
- data/spec/examples/syntax_error.js +3 -0
- data/spec/integration/examples_spec.rb +6 -0
- data/vendor/node_modules/traceur/LICENSE +202 -0
- data/vendor/node_modules/traceur/README.md +5 -5
- data/vendor/node_modules/traceur/bin/traceur-runtime.js +1392 -623
- data/vendor/node_modules/traceur/bin/traceur.js +24749 -17990
- data/vendor/node_modules/traceur/node_modules/.bin/semver +2 -2
- data/vendor/node_modules/traceur/node_modules/commander/History.md +222 -0
- data/vendor/node_modules/traceur/node_modules/commander/Readme.md +127 -35
- data/vendor/node_modules/traceur/node_modules/commander/index.js +261 -93
- data/vendor/node_modules/traceur/node_modules/commander/package.json +41 -9
- data/vendor/node_modules/traceur/node_modules/glob/LICENSE +15 -0
- data/vendor/node_modules/traceur/node_modules/glob/README.md +357 -0
- data/vendor/node_modules/traceur/node_modules/glob/common.js +177 -0
- data/vendor/node_modules/traceur/node_modules/glob/glob.js +649 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/.eslintrc +17 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/LICENSE +15 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/README.md +37 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/inflight.js +44 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +15 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +36 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +34 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +51 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +33 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/package.json +61 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inflight/test.js +97 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/LICENSE +16 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/README.md +42 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/inherits.js +1 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/package.json +33 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/inherits/test.js +25 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/.npmignore +1 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/.travis.yml +4 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/LICENSE +23 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/README.md +216 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/benchmark.js +15 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/browser.js +1181 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/minimatch.js +845 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +2 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +3 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +121 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
- data/vendor/node_modules/traceur/node_modules/{q-io/node_modules/collections → glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.travis.yml +0 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +73 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
- data/vendor/node_modules/traceur/node_modules/{q-io/node_modules/url2 → glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/.travis.yml +1 -1
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +83 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +75 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +32 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +1075 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +182 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +9 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +10 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +24 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +15 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +16 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +10 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +13 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +7 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +50 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/package.json +60 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/basic.js +399 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/brace-expand.js +45 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/defaults.js +274 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/LICENSE +27 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/README.md +51 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +15 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +34 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/once.js +21 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/package.json +42 -0
- data/vendor/node_modules/traceur/node_modules/glob/node_modules/once/test/once.js +23 -0
- data/vendor/node_modules/traceur/node_modules/glob/package.json +72 -0
- data/vendor/node_modules/traceur/node_modules/glob/sync.js +409 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/.release.json +17 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/CHANGELOG.md +165 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/README.md +364 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/dist/rsvp.js +1671 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/dist/rsvp.min.js +9 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp.js +66 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp.umd.js +50 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/-internal.js +265 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/all-settled.js +71 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/all.js +15 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/asap.js +109 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/config.js +28 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/defer.js +45 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/enumerator.js +125 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/events.js +201 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/filter.js +120 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/hash-settled.js +124 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/hash.js +94 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/instrument.js +41 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/map.js +99 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/node.js +281 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise-hash.js +51 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise.js +496 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/all.js +52 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/race.js +105 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/reject.js +47 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/promise/resolve.js +49 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/race.js +15 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/reject.js +16 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/resolve.js +17 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/rethrow.js +46 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/lib/rsvp/utils.js +39 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/package.json +100 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/README.md +9 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/bower.json +22 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/composer.json +18 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/package.json +52 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/rsvp.amd.js +1607 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/rsvp.js +1566 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/rsvp.js/rsvp.min.js +26 -0
- data/vendor/node_modules/traceur/node_modules/rsvp/vertx.js +1 -0
- data/vendor/node_modules/traceur/node_modules/semver/bin/semver +2 -2
- data/vendor/node_modules/traceur/node_modules/semver/package.json +4 -3
- data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +7 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.js +7 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -1
- data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/index.js +8 -4
- data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +2 -1
- data/vendor/node_modules/traceur/node_modules/source-map-support/.npmignore +1 -0
- data/vendor/node_modules/traceur/node_modules/{q-io/node_modules/mime/LICENSE → source-map-support/LICENSE.md} +7 -5
- data/vendor/node_modules/traceur/node_modules/source-map-support/README.md +165 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/browser-source-map-support.js +89 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/index.html +6 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/require.js +36 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/script.coffee +13 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/script.js +24 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/amd-test/script.map +10 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/browser-source-map-support.js +89 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/index.html +6 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/script.coffee +12 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/script.js +25 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/browser-test/script.map +10 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/build.js +69 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/index.html +6 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/script.coffee +12 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/script.js +25 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/script.map +10 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/header-test/server.js +45 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/.npmignore +2 -0
- data/vendor/node_modules/traceur/node_modules/{q-io → source-map-support/node_modules/source-map}/.travis.yml +1 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/CHANGELOG.md +121 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/LICENSE +28 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/Makefile.dryice.js +166 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/README.md +434 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/assert-shim.js +56 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/mini-require.js +152 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/prefix-source-map.jsm +20 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/prefix-utils.jsm +18 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-browser.js +8 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-source-map.jsm +6 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/suffix-utils.jsm +21 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/test-prefix.js +8 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/build/test-suffix.js +3 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map.js +8 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/array-set.js +97 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js +42 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/binary-search.js +81 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-consumer.js +478 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-generator.js +380 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-node.js +371 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/lib/source-map/util.js +205 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/README.md +171 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/intercept.js +36 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/node_modules/amdefine/package.json +37 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/package.json +142 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/run-tests.js +62 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-api.js +26 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-array-set.js +104 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-base64.js +35 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-map-consumer.js +451 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-map-generator.js +417 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/test-source-node.js +365 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/node_modules/source-map/test/source-map/util.js +161 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/package.json +52 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/source-map-support.js +381 -0
- data/vendor/node_modules/traceur/node_modules/source-map-support/test.js +359 -0
- data/vendor/node_modules/traceur/package.json +234 -20
- data/vendor/node_modules/traceur/src/node/NodeCompiler.js +78 -0
- data/vendor/node_modules/traceur/src/node/System.js +32 -5
- data/vendor/node_modules/traceur/src/node/api.js +28 -93
- data/vendor/node_modules/traceur/src/node/command.js +84 -19
- data/vendor/node_modules/traceur/src/node/compileAllJsFilesInDir.js +40 -0
- data/vendor/node_modules/traceur/src/node/interpreter.js +11 -8
- data/vendor/node_modules/traceur/src/node/recursiveModuleCompile.js +171 -0
- data/vendor/node_modules/traceur/src/node/require.js +7 -21
- data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +2 -7
- data/vendor/node_modules/traceur/src/node/to-closure-compiler.js +28 -0
- data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +3 -7
- data/vendor/node_modules/traceur/src/node/traceur.js +1 -1
- metadata +196 -190
- data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +0 -122
- data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +0 -19
- data/vendor/node_modules/traceur/node_modules/q-io/README.md +0 -928
- data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +0 -59
- data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +0 -44
- data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +0 -51
- data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +0 -307
- data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +0 -499
- data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +0 -547
- data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +0 -105
- data/vendor/node_modules/traceur/node_modules/q-io/fs.js +0 -355
- data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +0 -65
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +0 -152
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +0 -24
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +0 -93
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +0 -154
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +0 -178
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +0 -417
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +0 -58
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +0 -78
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +0 -120
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +0 -27
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +0 -209
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +0 -125
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +0 -175
- data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +0 -75
- data/vendor/node_modules/traceur/node_modules/q-io/http.js +0 -378
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +0 -11
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +0 -78
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +0 -21
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +0 -1285
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +0 -22
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +0 -142
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +0 -57
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +0 -183
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +0 -261
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +0 -186
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +0 -55
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +0 -59
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +0 -236
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +0 -371
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +0 -435
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +0 -247
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +0 -147
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +0 -448
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +0 -139
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +0 -79
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +0 -142
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +0 -60
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +0 -41
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +0 -12
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +0 -7
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +0 -48
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +0 -590
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +0 -49
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +0 -173
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +0 -274
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +0 -59
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +0 -538
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +0 -14
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +0 -6
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +0 -49
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +0 -51
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +0 -269
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +0 -61
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +0 -736
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +0 -40
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +0 -66
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +0 -114
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +0 -35
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +0 -84
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +0 -1588
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +0 -77
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +0 -15
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +0 -19
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +0 -96
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +0 -166
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +0 -43
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +0 -40
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +0 -19
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +0 -813
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +0 -71
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +0 -36
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +0 -93
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +0 -1937
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +0 -35
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +0 -6
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +0 -36
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +0 -7
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +0 -38
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +0 -32
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +0 -39
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +0 -2
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +0 -123
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +0 -19
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +0 -3
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +0 -3
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +0 -128
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +0 -53
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +0 -61
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +0 -856
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +0 -1080
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +0 -377
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +0 -290
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +0 -3
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +0 -42
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +0 -4
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +0 -16
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +0 -12
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +0 -91
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +0 -12
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +0 -13
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +0 -14
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +0 -146
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +0 -39
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +0 -48
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +0 -3
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +0 -22
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +0 -6
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +0 -248
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +0 -53
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +0 -2
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +0 -91
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +0 -548
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +0 -8
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +0 -358
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +0 -133
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +0 -3
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +0 -20
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +0 -33
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +0 -37
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +0 -125
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +0 -151
- data/vendor/node_modules/traceur/node_modules/q-io/package.json +0 -51
- data/vendor/node_modules/traceur/node_modules/q-io/reader.js +0 -133
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +0 -47
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +0 -11
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +0 -33
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +0 -92
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +0 -41
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +0 -57
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +0 -70
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +0 -109
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +0 -67
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +0 -219
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +0 -20
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +0 -26
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +0 -40
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +0 -37
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +0 -39
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +0 -32
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +0 -26
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +0 -86
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +0 -31
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +0 -73
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +0 -23
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +0 -22
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +0 -25
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +0 -45
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +0 -38
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +0 -52
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +0 -86
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +0 -1
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +0 -49
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +0 -47
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +0 -186
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +0 -82
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +0 -110
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +0 -96
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +0 -96
- data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +0 -42
- data/vendor/node_modules/traceur/node_modules/q-io/writer.js +0 -111
- data/vendor/node_modules/traceur/src/node/compile-single-file.js +0 -69
- data/vendor/node_modules/traceur/src/node/compiler.js +0 -116
- data/vendor/node_modules/traceur/src/node/inline-module.js +0 -149
@@ -1,125 +0,0 @@
|
|
1
|
-
|
2
|
-
var Q = require("q");
|
3
|
-
var StatusApps = require("./status");
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Makes a Q-JSGI app that only responds when there is nothing left
|
7
|
-
* on the path to route. If the there is unprocessed data on the
|
8
|
-
* path, the returned app either forwards to the `notFound` app or
|
9
|
-
* returns a `404 Not Found` response.
|
10
|
-
*
|
11
|
-
* @param {App} app a Q-JSGI application to
|
12
|
-
* respond to this end of the routing chain.
|
13
|
-
* @param {App} notFound (optional) defaults
|
14
|
-
* to the `notFound` app.
|
15
|
-
* @returns {App}
|
16
|
-
*/
|
17
|
-
exports.Cap = function (app, notFound) {
|
18
|
-
notFound = notFound || StatusApps.notFound;
|
19
|
-
return function (request, response) {
|
20
|
-
// TODO Distinguish these cases
|
21
|
-
if (request.pathInfo === "" || request.pathInfo === "/") {
|
22
|
-
return app(request, response);
|
23
|
-
} else {
|
24
|
-
return notFound(request, response);
|
25
|
-
}
|
26
|
-
};
|
27
|
-
};
|
28
|
-
|
29
|
-
/**
|
30
|
-
* Wraps an app with a function that will observe incoming requests
|
31
|
-
* before giving the app an opportunity to respond. If the "tap"
|
32
|
-
* function returns a response, it will be used in lieu of forwarding
|
33
|
-
* the request to the wrapped app.
|
34
|
-
*/
|
35
|
-
exports.Tap = function (app, tap) {
|
36
|
-
return function (request, response) {
|
37
|
-
var self = this, args = arguments;
|
38
|
-
return Q.when(tap.apply(this, arguments), function (response) {
|
39
|
-
if (response) {
|
40
|
-
return response;
|
41
|
-
} else {
|
42
|
-
return app.apply(self, args);
|
43
|
-
}
|
44
|
-
});
|
45
|
-
};
|
46
|
-
};
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Wraps an app with a "trap" function that intercepts and may
|
50
|
-
* alter or replace the response of the wrapped application.
|
51
|
-
*/
|
52
|
-
exports.Trap = function (app, trap) {
|
53
|
-
return function (request, response) {
|
54
|
-
return Q.when(app.apply(this, arguments), function (response) {
|
55
|
-
if (response) {
|
56
|
-
response.headers = response.headers || {};
|
57
|
-
return trap(response, request) || response;
|
58
|
-
}
|
59
|
-
});
|
60
|
-
};
|
61
|
-
};
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Makes a Q-JSGI app that branches requests based on the next
|
65
|
-
* unprocessed path component.
|
66
|
-
* @param {Object * App} paths a mapping from path components (single
|
67
|
-
* file or directory names) to Q-JSGI applications for subsequent
|
68
|
-
* routing. The mapping may be a plain JavaScript `Object` record,
|
69
|
-
* which must own the mapping properties, or an object that has
|
70
|
-
* `has(key)` and `get(key)` methods in its prototype chain.
|
71
|
-
* @param {App} notFound a Q-JSGI application
|
72
|
-
* that handles requests for which the next file name does not exist
|
73
|
-
* in paths.
|
74
|
-
* @returns {App}
|
75
|
-
*/
|
76
|
-
exports.Branch = function (paths, notFound) {
|
77
|
-
if (!paths)
|
78
|
-
paths = {};
|
79
|
-
if (!notFound)
|
80
|
-
notFound = StatusApps.notFound;
|
81
|
-
return function (request, response) {
|
82
|
-
if (!/^\//.test(request.pathInfo)) {
|
83
|
-
return notFound(request, response);
|
84
|
-
}
|
85
|
-
var path = request.pathInfo.slice(1);
|
86
|
-
var parts = path.split("/");
|
87
|
-
var part = decodeURIComponent(parts.shift());
|
88
|
-
if (Object.has(paths, part)) {
|
89
|
-
request.scriptName = request.scriptName + part + "/";
|
90
|
-
request.pathInfo = path.slice(part.length);
|
91
|
-
return Object.get(paths, part)(request, response);
|
92
|
-
}
|
93
|
-
return notFound(request, response);
|
94
|
-
};
|
95
|
-
};
|
96
|
-
|
97
|
-
/**
|
98
|
-
* Returns the response of the first application that returns a
|
99
|
-
* non-404 response status.
|
100
|
-
*
|
101
|
-
* @param {Array * App} apps a cascade of applications to try
|
102
|
-
* successively until one of them returns a non-404 status.
|
103
|
-
* @returns {App}
|
104
|
-
*/
|
105
|
-
exports.FirstFound = function (cascade) {
|
106
|
-
return function (request, response) {
|
107
|
-
var i = 0, ii = cascade.length;
|
108
|
-
function next() {
|
109
|
-
var response = cascade[i++](request, response);
|
110
|
-
if (i < ii) {
|
111
|
-
return Q.when(response, function (response) {
|
112
|
-
if (response.status === 404) {
|
113
|
-
return next();
|
114
|
-
} else {
|
115
|
-
return response;
|
116
|
-
}
|
117
|
-
});
|
118
|
-
} else {
|
119
|
-
return response;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
return next();
|
123
|
-
};
|
124
|
-
};
|
125
|
-
|
@@ -1,175 +0,0 @@
|
|
1
|
-
|
2
|
-
var Negotiation = require("./negotiate");
|
3
|
-
var HtmlApps = require("./html");
|
4
|
-
|
5
|
-
/**
|
6
|
-
* {Object * String} a mapping of HTTP status codes to
|
7
|
-
* their standard descriptions.
|
8
|
-
*/
|
9
|
-
// Every standard HTTP code mapped to the appropriate message.
|
10
|
-
// Stolen from Rack which stole from Mongrel
|
11
|
-
exports.statusCodes = {
|
12
|
-
100: 'Continue',
|
13
|
-
101: 'Switching Protocols',
|
14
|
-
102: 'Processing',
|
15
|
-
200: 'OK',
|
16
|
-
201: 'Created',
|
17
|
-
202: 'Accepted',
|
18
|
-
203: 'Non-Authoritative Information',
|
19
|
-
204: 'No Content',
|
20
|
-
205: 'Reset Content',
|
21
|
-
206: 'Partial Content',
|
22
|
-
207: 'Multi-Status',
|
23
|
-
300: 'Multiple Choices',
|
24
|
-
301: 'Moved Permanently',
|
25
|
-
302: 'Found',
|
26
|
-
303: 'See Other',
|
27
|
-
304: 'Not Modified',
|
28
|
-
305: 'Use Proxy',
|
29
|
-
307: 'Temporary Redirect',
|
30
|
-
400: 'Bad Request',
|
31
|
-
401: 'Unauthorized',
|
32
|
-
402: 'Payment Required',
|
33
|
-
403: 'Forbidden',
|
34
|
-
404: 'Not Found',
|
35
|
-
405: 'Method Not Allowed',
|
36
|
-
406: 'Not Acceptable',
|
37
|
-
407: 'Proxy Authentication Required',
|
38
|
-
408: 'Request Timeout',
|
39
|
-
409: 'Conflict',
|
40
|
-
410: 'Gone',
|
41
|
-
411: 'Length Required',
|
42
|
-
412: 'Precondition Failed',
|
43
|
-
413: 'Request Entity Too Large',
|
44
|
-
414: 'Request-URI Too Large',
|
45
|
-
415: 'Unsupported Media Type',
|
46
|
-
416: 'Request Range Not Satisfiable',
|
47
|
-
417: 'Expectation Failed',
|
48
|
-
422: 'Unprocessable Entity',
|
49
|
-
423: 'Locked',
|
50
|
-
424: 'Failed Dependency',
|
51
|
-
500: 'Internal Server Error',
|
52
|
-
501: 'Not Implemented',
|
53
|
-
502: 'Bad Gateway',
|
54
|
-
503: 'Service Unavailable',
|
55
|
-
504: 'Gateway Timeout',
|
56
|
-
505: 'HTTP Version Not Supported',
|
57
|
-
507: 'Insufficient Storage'
|
58
|
-
};
|
59
|
-
|
60
|
-
/**
|
61
|
-
* {Object * Number} a mapping from HTTP status descriptions
|
62
|
-
* to HTTP status codes.
|
63
|
-
*/
|
64
|
-
exports.statusMessages = {};
|
65
|
-
for (var code in exports.statusCodes)
|
66
|
-
exports.statusMessages[exports.statusCodes[code]] = +code;
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Determines whether an HTTP response should have a
|
70
|
-
* response body, based on its status code.
|
71
|
-
* @param {Number} status
|
72
|
-
* @returns whether the HTTP response for the given status
|
73
|
-
* code has content.
|
74
|
-
*/
|
75
|
-
exports.statusWithNoEntityBody = function (status) {
|
76
|
-
return (status >= 100 && status <= 199) ||
|
77
|
-
status == 204 || status == 304;
|
78
|
-
};
|
79
|
-
|
80
|
-
/**
|
81
|
-
* @param {Number} status
|
82
|
-
* @returns {Function(Request) :Response} a JSGI app that returns
|
83
|
-
* a plain text response with the given status code.
|
84
|
-
*/
|
85
|
-
exports.appForStatus = function (status) {
|
86
|
-
return function (request) {
|
87
|
-
return exports.responseForStatus(request, status, request.method + " " + request.path);
|
88
|
-
};
|
89
|
-
};
|
90
|
-
|
91
|
-
/**
|
92
|
-
* @param {Number} status an HTTP status code
|
93
|
-
* @param {String} message (optional) a message to include
|
94
|
-
* in the response body.
|
95
|
-
* @returns a JSGI HTTP response object with the given status
|
96
|
-
* code and message as its body, if the status supports
|
97
|
-
* a body.
|
98
|
-
*/
|
99
|
-
exports.responseForStatus = function(request, status, addendum) {
|
100
|
-
if (exports.statusCodes[status] === undefined)
|
101
|
-
throw "Unknown status code";
|
102
|
-
|
103
|
-
var message = exports.statusCodes[status];
|
104
|
-
|
105
|
-
// RFC 2616, 10.2.5:
|
106
|
-
// The 204 response MUST NOT include a message-body, and thus is always
|
107
|
-
// terminated by the first empty line after the header fields.
|
108
|
-
// RFC 2616, 10.3.5:
|
109
|
-
// The 304 response MUST NOT contain a message-body, and thus is always
|
110
|
-
// terminated by the first empty line after the header fields.
|
111
|
-
if (exports.statusWithNoEntityBody(status)) {
|
112
|
-
return {status: status, headers: {}};
|
113
|
-
} else {
|
114
|
-
var handlers = {};
|
115
|
-
handlers["text/plain"] = exports.textResponseForStatus;
|
116
|
-
if (request.handleHtmlFragmentResponse) {
|
117
|
-
handlers["text/html"] = exports.htmlResponseForStatus;
|
118
|
-
}
|
119
|
-
var responseForStatus = Negotiation.negotiate(request, handlers) || exports.textResponseForStatus;
|
120
|
-
return responseForStatus(request, status, message, addendum);
|
121
|
-
}
|
122
|
-
};
|
123
|
-
|
124
|
-
exports.textResponseForStatus = function (request, status, message, addendum) {
|
125
|
-
var content = message + "\n";
|
126
|
-
if (addendum) {
|
127
|
-
content += addendum + "\n";
|
128
|
-
}
|
129
|
-
var contentLength = content.length;
|
130
|
-
return {
|
131
|
-
status: status,
|
132
|
-
statusMessage: message,
|
133
|
-
headers: {
|
134
|
-
"content-length": contentLength
|
135
|
-
},
|
136
|
-
body: [content]
|
137
|
-
};
|
138
|
-
};
|
139
|
-
|
140
|
-
exports.htmlResponseForStatus = function (request, status, message, addendum) {
|
141
|
-
return {
|
142
|
-
status: status,
|
143
|
-
statusMessage: message,
|
144
|
-
headers: {},
|
145
|
-
htmlTitle: message,
|
146
|
-
htmlFragment: {
|
147
|
-
forEach: function (write) {
|
148
|
-
write("<h1>" + HtmlApps.escapeHtml(message) + "</h1>\n");
|
149
|
-
write("<p>Status: " + status + "</p>\n");
|
150
|
-
if (addendum) {
|
151
|
-
write("<pre>" + HtmlApps.escapeHtml(addendum) + "</pre>\n");
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}
|
155
|
-
}
|
156
|
-
};
|
157
|
-
|
158
|
-
/**
|
159
|
-
* {App} an application that returns a 400 response.
|
160
|
-
*/
|
161
|
-
exports.badRequest = exports.appForStatus(400);
|
162
|
-
/**
|
163
|
-
* {App} an application that returns a 404 response.
|
164
|
-
*/
|
165
|
-
exports.notFound = exports.appForStatus(404);
|
166
|
-
/**
|
167
|
-
* {App} an application that returns a 405 response.
|
168
|
-
*/
|
169
|
-
exports.methodNotAllowed = exports.appForStatus(405);
|
170
|
-
/**
|
171
|
-
* {App} an application that returns a 405 response.
|
172
|
-
*/
|
173
|
-
exports.noLanguage =
|
174
|
-
exports.notAcceptable = exports.appForStatus(406);
|
175
|
-
|
@@ -1,75 +0,0 @@
|
|
1
|
-
|
2
|
-
/**
|
3
|
-
* Provides utilities for reading and writing HTTP cookies.
|
4
|
-
* @module
|
5
|
-
*/
|
6
|
-
|
7
|
-
/*whatsupdoc*/
|
8
|
-
|
9
|
-
var QS = require("qs");
|
10
|
-
|
11
|
-
/**
|
12
|
-
* @param {String} cookie
|
13
|
-
* @returns {Object}
|
14
|
-
*/
|
15
|
-
exports.parse = function (cookie, date) {
|
16
|
-
date = date || new Date();
|
17
|
-
var parsed = {};
|
18
|
-
var terms = cookie.split(/[;,]/g);
|
19
|
-
var keyValue = terms.shift().split("=");
|
20
|
-
parsed.key = keyValue[0];
|
21
|
-
parsed.value = keyValue[1];
|
22
|
-
terms.forEach(function (term) {
|
23
|
-
var parts = term.split("=").map(function (part) {
|
24
|
-
return part.trim();
|
25
|
-
});
|
26
|
-
var key = parts[0], value = parts[1];
|
27
|
-
if (/^domain$/i.test(key)) {
|
28
|
-
parsed.domain = value;
|
29
|
-
} else if (/^path$/i.test(key)) {
|
30
|
-
parsed.path = value;
|
31
|
-
} else if (/^expires$/i.test(key)) {
|
32
|
-
parsed.expires = new Date(
|
33
|
-
+new Date() + // actual now
|
34
|
-
(new Date(value) - date) // server offset
|
35
|
-
);
|
36
|
-
} else if (/^max-age$/i.test(key)) {
|
37
|
-
parsed.expires = new Date(
|
38
|
-
new Date().getTime() +
|
39
|
-
(value * 1000)
|
40
|
-
);
|
41
|
-
} else if (/^secure$/i.test(key)) {
|
42
|
-
parsed.secure = true;
|
43
|
-
} else if (/^httponly$/i.test(key)) {
|
44
|
-
parsed.httpOnly = true;
|
45
|
-
}
|
46
|
-
});
|
47
|
-
return parsed;
|
48
|
-
};
|
49
|
-
|
50
|
-
/**
|
51
|
-
* @param {String} key
|
52
|
-
* @param {String} value
|
53
|
-
* @param {Object} options (optional)
|
54
|
-
* @returns {String} a cookie string
|
55
|
-
*/
|
56
|
-
exports.stringify = function (key, value, options) {
|
57
|
-
var cookie = (
|
58
|
-
encodeURIComponent(key) + "=" +
|
59
|
-
encodeURIComponent(value)
|
60
|
-
);
|
61
|
-
if (options) {
|
62
|
-
if (options.domain)
|
63
|
-
cookie += "; Domain=" + encodeURIComponent(options.domain);
|
64
|
-
if (options.path)
|
65
|
-
cookie += "; Path=" + encodeURIComponent(options.path);
|
66
|
-
if (options.expires)
|
67
|
-
cookie += "; Expires=" + options.expires.toGMTString();
|
68
|
-
if (options.secure)
|
69
|
-
cookie += "; Secure";
|
70
|
-
if (options.httpOnly)
|
71
|
-
cookie += "; HttpOnly";
|
72
|
-
}
|
73
|
-
return cookie;
|
74
|
-
};
|
75
|
-
|
@@ -1,378 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* A promise-based Q-JSGI server and client API.
|
3
|
-
* @module
|
4
|
-
*/
|
5
|
-
|
6
|
-
/*whatsupdoc*/
|
7
|
-
|
8
|
-
var HTTP = require("http"); // node
|
9
|
-
var HTTPS = require("https"); // node
|
10
|
-
var URL = require("url2"); // node
|
11
|
-
var Q = require("q");
|
12
|
-
var Reader = require("./reader");
|
13
|
-
|
14
|
-
/**
|
15
|
-
* @param {respond(request Request)} respond a JSGI responder function that
|
16
|
-
* receives a Request object as its argument. The JSGI responder promises to
|
17
|
-
* return an object of the form `{status, headers, body}`. The status and
|
18
|
-
* headers must be fully resolved, but the body may be a promise for an object
|
19
|
-
* with a `forEach(write(chunk String))` method, albeit an array of strings.
|
20
|
-
* The `forEach` method may promise to resolve when all chunks have been
|
21
|
-
* written.
|
22
|
-
* @returns a Node Server object.
|
23
|
-
*/
|
24
|
-
exports.Server = function (respond) {
|
25
|
-
var self = Object.create(exports.Server.prototype);
|
26
|
-
|
27
|
-
var server = HTTP.createServer(function (_request, _response) {
|
28
|
-
var request = exports.ServerRequest(_request);
|
29
|
-
var response = exports.ServerResponse(_response);
|
30
|
-
|
31
|
-
var closed = Q.defer();
|
32
|
-
_request.on("end", function (error, value) {
|
33
|
-
if (error) {
|
34
|
-
closed.reject(error);
|
35
|
-
} else {
|
36
|
-
closed.resolve(value);
|
37
|
-
}
|
38
|
-
});
|
39
|
-
|
40
|
-
Q.when(request, function (request) {
|
41
|
-
return Q.when(respond(request, response), function (response) {
|
42
|
-
if (!response)
|
43
|
-
return;
|
44
|
-
|
45
|
-
_response.writeHead(response.status, response.headers);
|
46
|
-
|
47
|
-
if (response.onclose || response.onClose)
|
48
|
-
Q.when(closed, response.onclose || response.onClose);
|
49
|
-
|
50
|
-
return Q.when(response.body, function (body) {
|
51
|
-
var length;
|
52
|
-
if (
|
53
|
-
Array.isArray(body) &&
|
54
|
-
(length = body.length) &&
|
55
|
-
body.every(function (chunk) {
|
56
|
-
return typeof chunk === "string"
|
57
|
-
})
|
58
|
-
) {
|
59
|
-
body.forEach(function (chunk, i) {
|
60
|
-
if (i < length - 1) {
|
61
|
-
_response.write(chunk, response.charset);
|
62
|
-
} else {
|
63
|
-
_response.end(chunk, response.charset);
|
64
|
-
}
|
65
|
-
});
|
66
|
-
} else if (body) {
|
67
|
-
var end;
|
68
|
-
var done = body.forEach(function (chunk) {
|
69
|
-
end = Q.when(end, function () {
|
70
|
-
return Q.when(chunk, function (chunk) {
|
71
|
-
_response.write(chunk, response.charset);
|
72
|
-
});
|
73
|
-
});
|
74
|
-
});
|
75
|
-
return Q.when(done, function () {
|
76
|
-
return Q.when(end, function () {
|
77
|
-
_response.end();
|
78
|
-
});
|
79
|
-
});
|
80
|
-
} else {
|
81
|
-
_response.end();
|
82
|
-
}
|
83
|
-
});
|
84
|
-
|
85
|
-
})
|
86
|
-
})
|
87
|
-
.done(); // should be .fail(self.emitter("error"))
|
88
|
-
|
89
|
-
});
|
90
|
-
|
91
|
-
var stopped = Q.defer();
|
92
|
-
server.on("close", function (err) {
|
93
|
-
if (err) {
|
94
|
-
stopped.reject(err);
|
95
|
-
} else {
|
96
|
-
stopped.resolve();
|
97
|
-
}
|
98
|
-
});
|
99
|
-
|
100
|
-
/***
|
101
|
-
* Stops the server.
|
102
|
-
* @returns {Promise * Undefined} a promise that will
|
103
|
-
* resolve when the server is stopped.
|
104
|
-
*/
|
105
|
-
self.stop = function () {
|
106
|
-
server.close();
|
107
|
-
listening = undefined;
|
108
|
-
return stopped.promise;
|
109
|
-
};
|
110
|
-
|
111
|
-
var listening = Q.defer();
|
112
|
-
server.on("listening", function (err) {
|
113
|
-
if (err) {
|
114
|
-
listening.reject(err);
|
115
|
-
} else {
|
116
|
-
listening.resolve(self);
|
117
|
-
}
|
118
|
-
});
|
119
|
-
|
120
|
-
/***
|
121
|
-
* Starts the server, listening on the given port
|
122
|
-
* @param {Number} port
|
123
|
-
* @returns {Promise * Undefined} a promise that will
|
124
|
-
* resolve when the server is ready to receive
|
125
|
-
* connections
|
126
|
-
*/
|
127
|
-
self.listen = function (/*...args*/) {
|
128
|
-
if (typeof server.port !== "undefined")
|
129
|
-
return Q.reject(new Error("A server cannot be restarted or " +
|
130
|
-
"started on a new port"));
|
131
|
-
server.listen.apply(server, arguments);
|
132
|
-
return listening.promise;
|
133
|
-
};
|
134
|
-
|
135
|
-
self.stopped = stopped.promise;
|
136
|
-
|
137
|
-
self.node = server;
|
138
|
-
self.nodeServer = server; // Deprecated
|
139
|
-
self.address = server.address.bind(server);
|
140
|
-
|
141
|
-
return self;
|
142
|
-
};
|
143
|
-
|
144
|
-
Object.defineProperties(exports.Server, {
|
145
|
-
|
146
|
-
port: {
|
147
|
-
get: function () {
|
148
|
-
return this.node.port;
|
149
|
-
}
|
150
|
-
},
|
151
|
-
|
152
|
-
host: {
|
153
|
-
get: function () {
|
154
|
-
return this.node.host;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
});
|
159
|
-
|
160
|
-
/**
|
161
|
-
* A wrapper for a Node HTTP Request, as received by
|
162
|
-
* the Q HTTP Server, suitable for use by the Q HTTP Client.
|
163
|
-
*/
|
164
|
-
exports.ServerRequest = function (_request, ssl) {
|
165
|
-
var request = Object.create(_request);
|
166
|
-
/*** {Array} HTTP version. (JSGI) */
|
167
|
-
request.version = _request.httpVersion.split(".").map(Math.floor);
|
168
|
-
/*** {String} HTTP method, e.g., `"GET"` (JSGI) */
|
169
|
-
request.method = _request.method;
|
170
|
-
/*** {String} path, starting with `"/"` */
|
171
|
-
request.path = _request.url;
|
172
|
-
/*** {String} pathInfo, starting with `"/"`, the
|
173
|
-
* portion of the path that has not yet
|
174
|
-
* been routed (JSGI) */
|
175
|
-
request.pathInfo = URL.parse(_request.url).pathname;
|
176
|
-
/*** {String} scriptName, the portion of the path that
|
177
|
-
* has already been routed (JSGI) */
|
178
|
-
request.scriptName = "";
|
179
|
-
/*** {String} (JSGI) */
|
180
|
-
request.scheme = "http";
|
181
|
-
|
182
|
-
var address = _request.connection.address();
|
183
|
-
/*** {String} hostname */
|
184
|
-
if (_request.headers.host) {
|
185
|
-
request.hostname = _request.headers.host.split(":")[0];
|
186
|
-
} else {
|
187
|
-
request.hostname = address.address;
|
188
|
-
}
|
189
|
-
/*** {String} host */
|
190
|
-
request.host = request.hostname + ":" + address.port;
|
191
|
-
request.port = address.port;
|
192
|
-
|
193
|
-
var socket = _request.socket;
|
194
|
-
/*** {String} */
|
195
|
-
request.remoteHost = socket.remoteAddress;
|
196
|
-
/*** {Number} */
|
197
|
-
request.remotePort = socket.remotePort;
|
198
|
-
|
199
|
-
/*** {String} url */
|
200
|
-
request.url = URL.format({
|
201
|
-
protocol: request.scheme,
|
202
|
-
host: _request.headers.host,
|
203
|
-
port: request.port === (ssl ? 443 : 80) ? null : request.port,
|
204
|
-
path: request.path
|
205
|
-
});
|
206
|
-
/*** A Q IO asynchronous text reader */
|
207
|
-
request.body = Reader(_request);
|
208
|
-
/*** {Object} HTTP headers (JSGI)*/
|
209
|
-
request.headers = _request.headers;
|
210
|
-
/*** The underlying Node request */
|
211
|
-
request.node = _request;
|
212
|
-
request.nodeRequest = _request; // Deprecated
|
213
|
-
/*** The underlying Node TCP connection */
|
214
|
-
request.nodeConnection = _request.connection;
|
215
|
-
|
216
|
-
return Q.when(request.body, function (body) {
|
217
|
-
request.body = body;
|
218
|
-
return request;
|
219
|
-
});
|
220
|
-
};
|
221
|
-
|
222
|
-
exports.ServerResponse = function (_response, ssl) {
|
223
|
-
var response = Object.create(_response);
|
224
|
-
response.ssl = ssl;
|
225
|
-
response.node = _response;
|
226
|
-
response.nodeResponse = _response; // Deprecated
|
227
|
-
return response;
|
228
|
-
};
|
229
|
-
|
230
|
-
exports.normalizeRequest = function (request) {
|
231
|
-
if (typeof request === "string") {
|
232
|
-
request = {
|
233
|
-
url: request
|
234
|
-
};
|
235
|
-
}
|
236
|
-
if (request.url) {
|
237
|
-
var url = URL.parse(request.url);
|
238
|
-
request.host = url.hostname;
|
239
|
-
request.port = url.port;
|
240
|
-
request.ssl = url.protocol === "https:";
|
241
|
-
request.method = request.method || "GET";
|
242
|
-
request.path = (url.pathname || "") + (url.search || "");
|
243
|
-
request.headers = request.headers || {};
|
244
|
-
request.headers.host = url.hostname; // FIXME name consistency
|
245
|
-
}
|
246
|
-
return request;
|
247
|
-
};
|
248
|
-
|
249
|
-
exports.normalizeResponse = function (response) {
|
250
|
-
if (response === void 0) {
|
251
|
-
return;
|
252
|
-
}
|
253
|
-
if (typeof response == "string") {
|
254
|
-
response = [response];
|
255
|
-
}
|
256
|
-
if (response.forEach) {
|
257
|
-
response = {
|
258
|
-
status: 200,
|
259
|
-
headers: {},
|
260
|
-
body: response
|
261
|
-
}
|
262
|
-
}
|
263
|
-
return response;
|
264
|
-
};
|
265
|
-
|
266
|
-
/**
|
267
|
-
* Issues an HTTP request.
|
268
|
-
*
|
269
|
-
* @param {Request {host, port, method, path, headers,
|
270
|
-
* body}} request (may be a promise)
|
271
|
-
* @returns {Promise * Response} promise for a response
|
272
|
-
*/
|
273
|
-
exports.request = function (request) {
|
274
|
-
return Q.when(request, function (request) {
|
275
|
-
|
276
|
-
request = exports.normalizeRequest(request);
|
277
|
-
|
278
|
-
var deferred = Q.defer();
|
279
|
-
var ssl = request.ssl;
|
280
|
-
var http = ssl ? HTTPS : HTTP;
|
281
|
-
|
282
|
-
var headers = request.headers || {};
|
283
|
-
|
284
|
-
headers.host = headers.host || request.host;
|
285
|
-
|
286
|
-
var _request = http.request({
|
287
|
-
"host": request.host,
|
288
|
-
"port": request.port || (ssl ? 443 : 80),
|
289
|
-
"path": request.path || "/",
|
290
|
-
"method": request.method || "GET",
|
291
|
-
"headers": headers,
|
292
|
-
"agent": request.agent
|
293
|
-
}, function (_response) {
|
294
|
-
deferred.resolve(exports.ClientResponse(_response, request.charset));
|
295
|
-
_response.on("error", function (error) {
|
296
|
-
// TODO find a better way to channel
|
297
|
-
// this into the response
|
298
|
-
console.warn(error && error.stack || error);
|
299
|
-
deferred.reject(error);
|
300
|
-
});
|
301
|
-
});
|
302
|
-
|
303
|
-
_request.on("error", function (error) {
|
304
|
-
deferred.reject(error);
|
305
|
-
});
|
306
|
-
|
307
|
-
Q.when(request.body, function (body) {
|
308
|
-
var end, done;
|
309
|
-
if (body) {
|
310
|
-
done = body.forEach(function (chunk) {
|
311
|
-
end = Q.when(end, function () {
|
312
|
-
return Q.when(chunk, function (chunk) {
|
313
|
-
_request.write(chunk, request.charset);
|
314
|
-
});
|
315
|
-
});
|
316
|
-
});
|
317
|
-
}
|
318
|
-
return Q.when(end, function () {
|
319
|
-
return Q.when(done, function () {
|
320
|
-
_request.end();
|
321
|
-
});
|
322
|
-
});
|
323
|
-
}).done();
|
324
|
-
|
325
|
-
return deferred.promise;
|
326
|
-
});
|
327
|
-
};
|
328
|
-
|
329
|
-
/**
|
330
|
-
* Issues a GET request to the given URL and returns
|
331
|
-
* a promise for a `String` containing the entirety
|
332
|
-
* of the response.
|
333
|
-
*
|
334
|
-
* @param {String} url
|
335
|
-
* @returns {Promise * String} or a rejection if the
|
336
|
-
* status code is not exactly 200. The reason for the
|
337
|
-
* rejection is the full response object.
|
338
|
-
*/
|
339
|
-
exports.read = function (request, qualifier) {
|
340
|
-
qualifier = qualifier || function (response) {
|
341
|
-
return response.status === 200;
|
342
|
-
};
|
343
|
-
return Q.when(exports.request(request), function (response) {
|
344
|
-
if (!qualifier(response)){
|
345
|
-
var error = new Error("HTTP request failed with code " + response.status);
|
346
|
-
error.response = response;
|
347
|
-
throw error;
|
348
|
-
}
|
349
|
-
return Q.post(response.body, 'read', []);
|
350
|
-
});
|
351
|
-
};
|
352
|
-
|
353
|
-
|
354
|
-
/**
|
355
|
-
* A wrapper for the Node HTTP Response as provided
|
356
|
-
* by the Q HTTP Client API, suitable for use by the
|
357
|
-
* Q HTTP Server API.
|
358
|
-
*/
|
359
|
-
exports.ClientResponse = function (_response, charset) {
|
360
|
-
var response = Object.create(exports.ClientResponse.prototype);
|
361
|
-
/*** {Number} HTTP status code */
|
362
|
-
response.status = _response.statusCode;
|
363
|
-
/*** HTTP version */
|
364
|
-
response.version = _response.httpVersion;
|
365
|
-
/*** {Object} HTTP headers */
|
366
|
-
response.headers = _response.headers;
|
367
|
-
/***
|
368
|
-
* A Q IO asynchronous text reader.
|
369
|
-
*/
|
370
|
-
response.node = _response;
|
371
|
-
response.nodeResponse = _response; // Deprecated
|
372
|
-
response.nodeConnection = _response.connection; // Deprecated
|
373
|
-
return Q.when(Reader(_response, charset), function (body) {
|
374
|
-
response.body = body;
|
375
|
-
return response;
|
376
|
-
});
|
377
|
-
};
|
378
|
-
|