freezerwatch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/freezerwatch +9 -0
- data/bin/setup +7 -0
- data/freezerwatch.gemspec +23 -0
- data/lib/freezerwatch.rb +5 -0
- data/lib/freezerwatch/version.rb +3 -0
- data/node_modules/.bin/freezerwatch +139 -0
- data/node_modules/freezerwatch/.npmignore +3 -0
- data/node_modules/freezerwatch/.ruby-version +1 -0
- data/node_modules/freezerwatch/Gemfile +4 -0
- data/node_modules/freezerwatch/Gemfile.lock +79 -0
- data/node_modules/freezerwatch/LICENSE +23 -0
- data/node_modules/freezerwatch/README.md +41 -0
- data/node_modules/freezerwatch/Rakefile +13 -0
- data/node_modules/freezerwatch/freezerwatch.js +139 -0
- data/node_modules/freezerwatch/metrics/bigfiles_high_water_mark +1 -0
- data/node_modules/freezerwatch/metrics/cane_high_water_mark +1 -0
- data/node_modules/freezerwatch/metrics/flay_high_water_mark +1 -0
- data/node_modules/freezerwatch/metrics/flog_high_water_mark +1 -0
- data/node_modules/freezerwatch/metrics/punchlist_high_water_mark +2 -0
- data/node_modules/freezerwatch/metrics/reek_high_water_mark +1 -0
- data/node_modules/freezerwatch/metrics/rubocop_high_water_mark +1 -0
- data/node_modules/freezerwatch/node_modules/async/.jshintrc +25 -0
- data/node_modules/freezerwatch/node_modules/async/.travis.yml +6 -0
- data/node_modules/freezerwatch/node_modules/async/CHANGELOG.md +65 -0
- data/node_modules/freezerwatch/node_modules/async/LICENSE +19 -0
- data/node_modules/freezerwatch/node_modules/async/README.md +1803 -0
- data/node_modules/freezerwatch/node_modules/async/bower.json +43 -0
- data/node_modules/freezerwatch/node_modules/async/component.json +17 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/base.css +182 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/index.html +73 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/base.css +182 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/index.html +73 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/async.js.html +3900 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/index.html +73 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.css +1 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.js +1 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sorter.js +156 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lcov.info +1452 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lib/async.js.html +3597 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/lib/index.html +73 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/prettify.css +1 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/prettify.js +1 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/sort-arrow-sprite.png +0 -0
- data/node_modules/freezerwatch/node_modules/async/coverage/sorter.js +156 -0
- data/node_modules/freezerwatch/node_modules/async/lib/async.js +1191 -0
- data/node_modules/freezerwatch/node_modules/async/nyc_output/5074.json +1 -0
- data/node_modules/freezerwatch/node_modules/async/package.json +96 -0
- data/node_modules/freezerwatch/node_modules/async/support/sync-package-managers.js +53 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/.npmignore +15 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/Client.js +60 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/Device.js +38 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/DeviceRawReadStream.js +36 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/DeviceSingleRawReadStream.js +29 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js +35 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/LICENSE +23 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/README.md +25 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/index.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.npmignore +2 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.travis.yml +12 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/LICENSE +55 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/README.md +364 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/index.js +156 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/copy.js +8 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/debug.js +7 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/getSafe.js +34 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/optional.js +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/.bin/uuid +26 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/LICENSE +55 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/README.md +4 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/index.js +202 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/package.json +46 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/LICENSE +55 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/README.md +4 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/index.js +119 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/package.json +45 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/License +19 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/Readme.md +175 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/lib/form_data.js +351 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +19 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/README.md +1647 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/bower.json +38 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/component.json +16 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +1123 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/package.json +84 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/support/sync-package-managers.js +53 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +19 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +132 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +188 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +2 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +19 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +7 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +154 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +99 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +42 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +6 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +38 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +21 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +14 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +48 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +15 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +13 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +13 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +7 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +60 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/package.json +80 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.npmignore +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.travis.yml +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/LICENSE +24 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/Makefile +10 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/README.md +627 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/example/usage.js +78 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/logo.png +0 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/index.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/browser.js +485 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/client.js +367 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/crypto.js +111 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/index.js +15 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/server.js +524 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/utils.js +183 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +24 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +11 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/README.md +6 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/index.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +207 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/package.json +64 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +245 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +24 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +11 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +6 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +68 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +65 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +101 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +33 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +10 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +436 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +132 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +585 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +70 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +86 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +1078 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +5 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +24 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +11 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +68 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +16 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +25 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +409 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +65 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +359 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/package.json +70 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/browser.js +771 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/client.js +206 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/crypto.js +86 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/index.js +316 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/message.js +246 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/readme.js +98 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/server.js +686 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/uri.js +456 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/utils.js +120 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.dir-locals.el +6 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.npmignore +7 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/LICENSE +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/README.md +79 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/http_signing.md +296 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/index.js +26 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/parser.js +304 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/signer.js +178 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/util.js +304 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/verify.js +42 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +2 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +19 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +50 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +13 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +27 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +267 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +36 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +317 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +20 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +63 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +172 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +296 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +126 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +245 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +45 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/.npmignore +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +78 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +24 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README +82 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +298 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +245 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +1485 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +944 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +241 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +42 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +129 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +839 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/package.json +72 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/.npmignore +1 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/LICENSE +15 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/Makefile +35 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/README.md +52 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/package.json +68 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/stringify.js +27 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/mocha.opts +2 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/LICENSE +19 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/README.md +66 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/mime.js +114 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/package.json +57 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/test.js +84 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/mime.types +1588 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/node.types +77 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/.npmignore +2 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/LICENSE.md +21 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/README.md +243 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/README.md +53 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +174 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +34 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +34 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +84 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bin/uuid +26 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bower.json +23 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/component.json +18 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/package.json +65 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/compare_v1.js +63 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.html +17 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.js +228 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/uuid.js +247 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/LICENSE +55 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/README.md +4 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/index.js +43 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/package.json +48 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/test.js +49 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.gitmodules +6 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.npmignore +7 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/Readme.md +58 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/index.js +366 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/package.json +55 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.jshintrc +72 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.npmignore +3 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/LICENSE +78 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/README.md +380 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +230 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/cookie.js +947 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/memstore.js +102 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +69 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +20 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +176 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +81 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +530 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/package.json +63 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/public-suffix.txt +5229 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/test.js +1340 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/LICENSE +55 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/README.md +4 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/index.js +227 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/package.json +45 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/package.json +74 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/request.js +1244 -0
- data/node_modules/freezerwatch/node_modules/lacrosse/package.json +34 -0
- data/node_modules/freezerwatch/node_modules/optparse/README.md +163 -0
- data/node_modules/freezerwatch/node_modules/optparse/TODO +1 -0
- data/node_modules/freezerwatch/node_modules/optparse/examples/browser-test.html +75 -0
- data/node_modules/freezerwatch/node_modules/optparse/examples/nodejs-test.js +86 -0
- data/node_modules/freezerwatch/node_modules/optparse/lib/optparse.js +309 -0
- data/node_modules/freezerwatch/node_modules/optparse/package.json +46 -0
- data/node_modules/freezerwatch/node_modules/optparse/seed.yml +5 -0
- data/node_modules/freezerwatch/node_modules/osenv/.npmignore +13 -0
- data/node_modules/freezerwatch/node_modules/osenv/.travis.yml +9 -0
- data/node_modules/freezerwatch/node_modules/osenv/LICENSE +15 -0
- data/node_modules/freezerwatch/node_modules/osenv/README.md +63 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/index.js +24 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/license +21 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/package.json +70 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/readme.md +33 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/index.js +25 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/license +21 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/package.json +70 -0
- data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/readme.md +36 -0
- data/node_modules/freezerwatch/node_modules/osenv/osenv.js +72 -0
- data/node_modules/freezerwatch/node_modules/osenv/package.json +76 -0
- data/node_modules/freezerwatch/node_modules/osenv/test/unix.js +71 -0
- data/node_modules/freezerwatch/node_modules/osenv/test/windows.js +74 -0
- data/node_modules/freezerwatch/node_modules/osenv/x.tap +39 -0
- data/node_modules/freezerwatch/package.json +37 -0
- metadata +384 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
module.exports = ForeverAgent
|
2
|
+
ForeverAgent.SSL = ForeverAgentSSL
|
3
|
+
|
4
|
+
var util = require('util')
|
5
|
+
, Agent = require('http').Agent
|
6
|
+
, net = require('net')
|
7
|
+
, tls = require('tls')
|
8
|
+
, AgentSSL = require('https').Agent
|
9
|
+
|
10
|
+
function ForeverAgent(options) {
|
11
|
+
var self = this
|
12
|
+
self.options = options || {}
|
13
|
+
self.requests = {}
|
14
|
+
self.sockets = {}
|
15
|
+
self.freeSockets = {}
|
16
|
+
self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets
|
17
|
+
self.minSockets = self.options.minSockets || ForeverAgent.defaultMinSockets
|
18
|
+
self.on('free', function(socket, host, port) {
|
19
|
+
var name = host + ':' + port
|
20
|
+
if (self.requests[name] && self.requests[name].length) {
|
21
|
+
self.requests[name].shift().onSocket(socket)
|
22
|
+
} else if (self.sockets[name].length < self.minSockets) {
|
23
|
+
if (!self.freeSockets[name]) self.freeSockets[name] = []
|
24
|
+
self.freeSockets[name].push(socket)
|
25
|
+
|
26
|
+
// if an error happens while we don't use the socket anyway, meh, throw the socket away
|
27
|
+
var onIdleError = function() {
|
28
|
+
socket.destroy()
|
29
|
+
}
|
30
|
+
socket._onIdleError = onIdleError
|
31
|
+
socket.on('error', onIdleError)
|
32
|
+
} else {
|
33
|
+
// If there are no pending requests just destroy the
|
34
|
+
// socket and it will get removed from the pool. This
|
35
|
+
// gets us out of timeout issues and allows us to
|
36
|
+
// default to Connection:keep-alive.
|
37
|
+
socket.destroy()
|
38
|
+
}
|
39
|
+
})
|
40
|
+
|
41
|
+
}
|
42
|
+
util.inherits(ForeverAgent, Agent)
|
43
|
+
|
44
|
+
ForeverAgent.defaultMinSockets = 5
|
45
|
+
|
46
|
+
|
47
|
+
ForeverAgent.prototype.createConnection = net.createConnection
|
48
|
+
ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest
|
49
|
+
ForeverAgent.prototype.addRequest = function(req, host, port) {
|
50
|
+
var name = host + ':' + port
|
51
|
+
if (this.freeSockets[name] && this.freeSockets[name].length > 0 && !req.useChunkedEncodingByDefault) {
|
52
|
+
var idleSocket = this.freeSockets[name].pop()
|
53
|
+
idleSocket.removeListener('error', idleSocket._onIdleError)
|
54
|
+
delete idleSocket._onIdleError
|
55
|
+
req._reusedSocket = true
|
56
|
+
req.onSocket(idleSocket)
|
57
|
+
} else {
|
58
|
+
this.addRequestNoreuse(req, host, port)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
ForeverAgent.prototype.removeSocket = function(s, name, host, port) {
|
63
|
+
if (this.sockets[name]) {
|
64
|
+
var index = this.sockets[name].indexOf(s)
|
65
|
+
if (index !== -1) {
|
66
|
+
this.sockets[name].splice(index, 1)
|
67
|
+
}
|
68
|
+
} else if (this.sockets[name] && this.sockets[name].length === 0) {
|
69
|
+
// don't leak
|
70
|
+
delete this.sockets[name]
|
71
|
+
delete this.requests[name]
|
72
|
+
}
|
73
|
+
|
74
|
+
if (this.freeSockets[name]) {
|
75
|
+
var index = this.freeSockets[name].indexOf(s)
|
76
|
+
if (index !== -1) {
|
77
|
+
this.freeSockets[name].splice(index, 1)
|
78
|
+
if (this.freeSockets[name].length === 0) {
|
79
|
+
delete this.freeSockets[name]
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
if (this.requests[name] && this.requests[name].length) {
|
85
|
+
// If we have pending requests and a socket gets closed a new one
|
86
|
+
// needs to be created to take over in the pool for the one that closed.
|
87
|
+
this.createSocket(name, host, port).emit('free')
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
function ForeverAgentSSL (options) {
|
92
|
+
ForeverAgent.call(this, options)
|
93
|
+
}
|
94
|
+
util.inherits(ForeverAgentSSL, ForeverAgent)
|
95
|
+
|
96
|
+
ForeverAgentSSL.prototype.createConnection = createConnectionSSL
|
97
|
+
ForeverAgentSSL.prototype.addRequestNoreuse = AgentSSL.prototype.addRequest
|
98
|
+
|
99
|
+
function createConnectionSSL (port, host, options) {
|
100
|
+
if (typeof port === 'object') {
|
101
|
+
options = port;
|
102
|
+
} else if (typeof host === 'object') {
|
103
|
+
options = host;
|
104
|
+
} else if (typeof options === 'object') {
|
105
|
+
options = options;
|
106
|
+
} else {
|
107
|
+
options = {};
|
108
|
+
}
|
109
|
+
|
110
|
+
if (typeof port === 'number') {
|
111
|
+
options.port = port;
|
112
|
+
}
|
113
|
+
|
114
|
+
if (typeof host === 'string') {
|
115
|
+
options.host = host;
|
116
|
+
}
|
117
|
+
|
118
|
+
return tls.connect(options);
|
119
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"author": {
|
3
|
+
"name": "Mikeal Rogers",
|
4
|
+
"email": "mikeal.rogers@gmail.com",
|
5
|
+
"url": "http://www.futurealoof.com"
|
6
|
+
},
|
7
|
+
"name": "forever-agent",
|
8
|
+
"description": "HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.",
|
9
|
+
"version": "0.5.2",
|
10
|
+
"repository": {
|
11
|
+
"url": "git+https://github.com/mikeal/forever-agent.git"
|
12
|
+
},
|
13
|
+
"main": "index.js",
|
14
|
+
"dependencies": {},
|
15
|
+
"devDependencies": {},
|
16
|
+
"optionalDependencies": {},
|
17
|
+
"engines": {
|
18
|
+
"node": "*"
|
19
|
+
},
|
20
|
+
"bugs": {
|
21
|
+
"url": "https://github.com/mikeal/forever-agent/issues"
|
22
|
+
},
|
23
|
+
"homepage": "https://github.com/mikeal/forever-agent",
|
24
|
+
"_id": "forever-agent@0.5.2",
|
25
|
+
"dist": {
|
26
|
+
"shasum": "6d0e09c4921f94a27f63d3b49c5feff1ea4c5130",
|
27
|
+
"tarball": "http://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz"
|
28
|
+
},
|
29
|
+
"_from": "forever-agent@>=0.5.0 <0.6.0",
|
30
|
+
"_npmVersion": "1.3.21",
|
31
|
+
"_npmUser": {
|
32
|
+
"name": "mikeal",
|
33
|
+
"email": "mikeal.rogers@gmail.com"
|
34
|
+
},
|
35
|
+
"maintainers": [
|
36
|
+
{
|
37
|
+
"name": "mikeal",
|
38
|
+
"email": "mikeal.rogers@gmail.com"
|
39
|
+
}
|
40
|
+
],
|
41
|
+
"directories": {},
|
42
|
+
"_shasum": "6d0e09c4921f94a27f63d3b49c5feff1ea4c5130",
|
43
|
+
"_resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz",
|
44
|
+
"readme": "ERROR: No README data found!"
|
45
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# Form-Data [![Build Status](https://travis-ci.org/felixge/node-form-data.png?branch=master)](https://travis-ci.org/felixge/node-form-data) [![Dependency Status](https://gemnasium.com/felixge/node-form-data.png)](https://gemnasium.com/felixge/node-form-data)
|
2
|
+
|
3
|
+
A module to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
4
|
+
|
5
|
+
The API of this module is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
6
|
+
|
7
|
+
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
8
|
+
[streams2-thing]: http://nodejs.org/api/stream.html#stream_compatibility_with_older_node_versions
|
9
|
+
|
10
|
+
## Install
|
11
|
+
|
12
|
+
```
|
13
|
+
npm install form-data
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
In this example we are constructing a form with 3 fields that contain a string,
|
19
|
+
a buffer and a file stream.
|
20
|
+
|
21
|
+
``` javascript
|
22
|
+
var FormData = require('form-data');
|
23
|
+
var fs = require('fs');
|
24
|
+
|
25
|
+
var form = new FormData();
|
26
|
+
form.append('my_field', 'my value');
|
27
|
+
form.append('my_buffer', new Buffer(10));
|
28
|
+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
29
|
+
```
|
30
|
+
|
31
|
+
Also you can use http-response stream:
|
32
|
+
|
33
|
+
``` javascript
|
34
|
+
var FormData = require('form-data');
|
35
|
+
var http = require('http');
|
36
|
+
|
37
|
+
var form = new FormData();
|
38
|
+
|
39
|
+
http.request('http://nodejs.org/images/logo.png', function(response) {
|
40
|
+
form.append('my_field', 'my value');
|
41
|
+
form.append('my_buffer', new Buffer(10));
|
42
|
+
form.append('my_logo', response);
|
43
|
+
});
|
44
|
+
```
|
45
|
+
|
46
|
+
Or @mikeal's request stream:
|
47
|
+
|
48
|
+
``` javascript
|
49
|
+
var FormData = require('form-data');
|
50
|
+
var request = require('request');
|
51
|
+
|
52
|
+
var form = new FormData();
|
53
|
+
|
54
|
+
form.append('my_field', 'my value');
|
55
|
+
form.append('my_buffer', new Buffer(10));
|
56
|
+
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
57
|
+
```
|
58
|
+
|
59
|
+
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
60
|
+
|
61
|
+
``` javascript
|
62
|
+
form.submit('http://example.org/', function(err, res) {
|
63
|
+
// res – response object (http.IncomingMessage) //
|
64
|
+
res.resume(); // for node-0.10.x
|
65
|
+
});
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
70
|
+
|
71
|
+
### Alternative submission methods
|
72
|
+
|
73
|
+
You can use node's http client interface:
|
74
|
+
|
75
|
+
``` javascript
|
76
|
+
var http = require('http');
|
77
|
+
|
78
|
+
var request = http.request({
|
79
|
+
method: 'post',
|
80
|
+
host: 'example.org',
|
81
|
+
path: '/upload',
|
82
|
+
headers: form.getHeaders()
|
83
|
+
});
|
84
|
+
|
85
|
+
form.pipe(request);
|
86
|
+
|
87
|
+
request.on('response', function(res) {
|
88
|
+
console.log(res.statusCode);
|
89
|
+
});
|
90
|
+
```
|
91
|
+
|
92
|
+
Or if you would prefer the `'Content-Length'` header to be set for you:
|
93
|
+
|
94
|
+
``` javascript
|
95
|
+
form.submit('example.org/upload', function(err, res) {
|
96
|
+
console.log(res.statusCode);
|
97
|
+
});
|
98
|
+
```
|
99
|
+
|
100
|
+
To use custom headers and pre-known length in parts:
|
101
|
+
|
102
|
+
``` javascript
|
103
|
+
var CRLF = '\r\n';
|
104
|
+
var form = new FormData();
|
105
|
+
|
106
|
+
var options = {
|
107
|
+
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
108
|
+
knownLength: 1
|
109
|
+
};
|
110
|
+
|
111
|
+
form.append('my_buffer', buffer, options);
|
112
|
+
|
113
|
+
form.submit('http://example.com/', function(err, res) {
|
114
|
+
if (err) throw err;
|
115
|
+
console.log('Done');
|
116
|
+
});
|
117
|
+
```
|
118
|
+
|
119
|
+
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
|
120
|
+
|
121
|
+
``` javascript
|
122
|
+
someModule.stream(function(err, stdout, stderr) {
|
123
|
+
if (err) throw err;
|
124
|
+
|
125
|
+
var form = new FormData();
|
126
|
+
|
127
|
+
form.append('file', stdout, {
|
128
|
+
filename: 'unicycle.jpg',
|
129
|
+
contentType: 'image/jpg',
|
130
|
+
knownLength: 19806
|
131
|
+
});
|
132
|
+
|
133
|
+
form.submit('http://example.com/', function(err, res) {
|
134
|
+
if (err) throw err;
|
135
|
+
console.log('Done');
|
136
|
+
});
|
137
|
+
});
|
138
|
+
```
|
139
|
+
|
140
|
+
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
|
141
|
+
|
142
|
+
``` javascript
|
143
|
+
form.submit({
|
144
|
+
host: 'example.com',
|
145
|
+
path: '/probably.php?extra=params',
|
146
|
+
auth: 'username:password'
|
147
|
+
}, function(err, res) {
|
148
|
+
console.log(res.statusCode);
|
149
|
+
});
|
150
|
+
```
|
151
|
+
|
152
|
+
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
|
153
|
+
|
154
|
+
``` javascript
|
155
|
+
form.submit({
|
156
|
+
host: 'example.com',
|
157
|
+
path: '/surelynot.php',
|
158
|
+
headers: {'x-test-header': 'test-header-value'}
|
159
|
+
}, function(err, res) {
|
160
|
+
console.log(res.statusCode);
|
161
|
+
});
|
162
|
+
```
|
163
|
+
|
164
|
+
## Notes
|
165
|
+
|
166
|
+
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
167
|
+
- If it feels like FormData hangs after submit and you're on ```node-0.10```, please check [Compatibility with Older Node Versions][streams2-thing]
|
168
|
+
|
169
|
+
## TODO
|
170
|
+
|
171
|
+
- Add new streams (0.10) support and try really hard not to break it for 0.8.x.
|
172
|
+
|
173
|
+
## License
|
174
|
+
|
175
|
+
Form-Data is licensed under the MIT license.
|
@@ -0,0 +1,351 @@
|
|
1
|
+
var CombinedStream = require('combined-stream');
|
2
|
+
var util = require('util');
|
3
|
+
var path = require('path');
|
4
|
+
var http = require('http');
|
5
|
+
var https = require('https');
|
6
|
+
var parseUrl = require('url').parse;
|
7
|
+
var fs = require('fs');
|
8
|
+
var mime = require('mime');
|
9
|
+
var async = require('async');
|
10
|
+
|
11
|
+
module.exports = FormData;
|
12
|
+
function FormData() {
|
13
|
+
this._overheadLength = 0;
|
14
|
+
this._valueLength = 0;
|
15
|
+
this._lengthRetrievers = [];
|
16
|
+
|
17
|
+
CombinedStream.call(this);
|
18
|
+
}
|
19
|
+
util.inherits(FormData, CombinedStream);
|
20
|
+
|
21
|
+
FormData.LINE_BREAK = '\r\n';
|
22
|
+
|
23
|
+
FormData.prototype.append = function(field, value, options) {
|
24
|
+
options = options || {};
|
25
|
+
|
26
|
+
var append = CombinedStream.prototype.append.bind(this);
|
27
|
+
|
28
|
+
// all that streamy business can't handle numbers
|
29
|
+
if (typeof value == 'number') value = ''+value;
|
30
|
+
|
31
|
+
// https://github.com/felixge/node-form-data/issues/38
|
32
|
+
if (util.isArray(value)) {
|
33
|
+
// Please convert your array into string
|
34
|
+
// the way web server expects it
|
35
|
+
this._error(new Error('Arrays are not supported.'));
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
|
39
|
+
var header = this._multiPartHeader(field, value, options);
|
40
|
+
var footer = this._multiPartFooter(field, value, options);
|
41
|
+
|
42
|
+
append(header);
|
43
|
+
append(value);
|
44
|
+
append(footer);
|
45
|
+
|
46
|
+
// pass along options.knownLength
|
47
|
+
this._trackLength(header, value, options);
|
48
|
+
};
|
49
|
+
|
50
|
+
FormData.prototype._trackLength = function(header, value, options) {
|
51
|
+
var valueLength = 0;
|
52
|
+
|
53
|
+
// used w/ getLengthSync(), when length is known.
|
54
|
+
// e.g. for streaming directly from a remote server,
|
55
|
+
// w/ a known file a size, and not wanting to wait for
|
56
|
+
// incoming file to finish to get its size.
|
57
|
+
if (options.knownLength != null) {
|
58
|
+
valueLength += +options.knownLength;
|
59
|
+
} else if (Buffer.isBuffer(value)) {
|
60
|
+
valueLength = value.length;
|
61
|
+
} else if (typeof value === 'string') {
|
62
|
+
valueLength = Buffer.byteLength(value);
|
63
|
+
}
|
64
|
+
|
65
|
+
this._valueLength += valueLength;
|
66
|
+
|
67
|
+
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
68
|
+
this._overheadLength +=
|
69
|
+
Buffer.byteLength(header) +
|
70
|
+
+ FormData.LINE_BREAK.length;
|
71
|
+
|
72
|
+
// empty or either doesn't have path or not an http response
|
73
|
+
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) {
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
// no need to bother with the length
|
78
|
+
if (!options.knownLength)
|
79
|
+
this._lengthRetrievers.push(function(next) {
|
80
|
+
|
81
|
+
if (value.hasOwnProperty('fd')) {
|
82
|
+
|
83
|
+
// take read range into a account
|
84
|
+
// `end` = Infinity –> read file till the end
|
85
|
+
//
|
86
|
+
// TODO: Looks like there is bug in Node fs.createReadStream
|
87
|
+
// it doesn't respect `end` options without `start` options
|
88
|
+
// Fix it when node fixes it.
|
89
|
+
// https://github.com/joyent/node/issues/7819
|
90
|
+
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
91
|
+
|
92
|
+
// when end specified
|
93
|
+
// no need to calculate range
|
94
|
+
// inclusive, starts with 0
|
95
|
+
next(null, value.end+1 - (value.start ? value.start : 0));
|
96
|
+
|
97
|
+
// not that fast snoopy
|
98
|
+
} else {
|
99
|
+
// still need to fetch file size from fs
|
100
|
+
fs.stat(value.path, function(err, stat) {
|
101
|
+
|
102
|
+
var fileSize;
|
103
|
+
|
104
|
+
if (err) {
|
105
|
+
next(err);
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
// update final size based on the range options
|
110
|
+
fileSize = stat.size - (value.start ? value.start : 0);
|
111
|
+
next(null, fileSize);
|
112
|
+
});
|
113
|
+
}
|
114
|
+
|
115
|
+
// or http response
|
116
|
+
} else if (value.hasOwnProperty('httpVersion')) {
|
117
|
+
next(null, +value.headers['content-length']);
|
118
|
+
|
119
|
+
// or request stream http://github.com/mikeal/request
|
120
|
+
} else if (value.hasOwnProperty('httpModule')) {
|
121
|
+
// wait till response come back
|
122
|
+
value.on('response', function(response) {
|
123
|
+
value.pause();
|
124
|
+
next(null, +response.headers['content-length']);
|
125
|
+
});
|
126
|
+
value.resume();
|
127
|
+
|
128
|
+
// something else
|
129
|
+
} else {
|
130
|
+
next('Unknown stream');
|
131
|
+
}
|
132
|
+
});
|
133
|
+
};
|
134
|
+
|
135
|
+
FormData.prototype._multiPartHeader = function(field, value, options) {
|
136
|
+
var boundary = this.getBoundary();
|
137
|
+
var header = '';
|
138
|
+
|
139
|
+
// custom header specified (as string)?
|
140
|
+
// it becomes responsible for boundary
|
141
|
+
// (e.g. to handle extra CRLFs on .NET servers)
|
142
|
+
if (options.header != null) {
|
143
|
+
header = options.header;
|
144
|
+
} else {
|
145
|
+
header += '--' + boundary + FormData.LINE_BREAK +
|
146
|
+
'Content-Disposition: form-data; name="' + field + '"';
|
147
|
+
|
148
|
+
// fs- and request- streams have path property
|
149
|
+
// or use custom filename and/or contentType
|
150
|
+
// TODO: Use request's response mime-type
|
151
|
+
if (options.filename || value.path) {
|
152
|
+
header +=
|
153
|
+
'; filename="' + path.basename(options.filename || value.path) + '"' + FormData.LINE_BREAK +
|
154
|
+
'Content-Type: ' + (options.contentType || mime.lookup(options.filename || value.path));
|
155
|
+
|
156
|
+
// http response has not
|
157
|
+
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
158
|
+
header +=
|
159
|
+
'; filename="' + path.basename(value.client._httpMessage.path) + '"' + FormData.LINE_BREAK +
|
160
|
+
'Content-Type: ' + value.headers['content-type'];
|
161
|
+
}
|
162
|
+
|
163
|
+
header += FormData.LINE_BREAK + FormData.LINE_BREAK;
|
164
|
+
}
|
165
|
+
|
166
|
+
return header;
|
167
|
+
};
|
168
|
+
|
169
|
+
FormData.prototype._multiPartFooter = function(field, value, options) {
|
170
|
+
return function(next) {
|
171
|
+
var footer = FormData.LINE_BREAK;
|
172
|
+
|
173
|
+
var lastPart = (this._streams.length === 0);
|
174
|
+
if (lastPart) {
|
175
|
+
footer += this._lastBoundary();
|
176
|
+
}
|
177
|
+
|
178
|
+
next(footer);
|
179
|
+
}.bind(this);
|
180
|
+
};
|
181
|
+
|
182
|
+
FormData.prototype._lastBoundary = function() {
|
183
|
+
return '--' + this.getBoundary() + '--';
|
184
|
+
};
|
185
|
+
|
186
|
+
FormData.prototype.getHeaders = function(userHeaders) {
|
187
|
+
var formHeaders = {
|
188
|
+
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
189
|
+
};
|
190
|
+
|
191
|
+
for (var header in userHeaders) {
|
192
|
+
formHeaders[header.toLowerCase()] = userHeaders[header];
|
193
|
+
}
|
194
|
+
|
195
|
+
return formHeaders;
|
196
|
+
}
|
197
|
+
|
198
|
+
FormData.prototype.getCustomHeaders = function(contentType) {
|
199
|
+
contentType = contentType ? contentType : 'multipart/form-data';
|
200
|
+
|
201
|
+
var formHeaders = {
|
202
|
+
'content-type': contentType + '; boundary=' + this.getBoundary(),
|
203
|
+
'content-length': this.getLengthSync()
|
204
|
+
};
|
205
|
+
|
206
|
+
return formHeaders;
|
207
|
+
}
|
208
|
+
|
209
|
+
FormData.prototype.getBoundary = function() {
|
210
|
+
if (!this._boundary) {
|
211
|
+
this._generateBoundary();
|
212
|
+
}
|
213
|
+
|
214
|
+
return this._boundary;
|
215
|
+
};
|
216
|
+
|
217
|
+
FormData.prototype._generateBoundary = function() {
|
218
|
+
// This generates a 50 character boundary similar to those used by Firefox.
|
219
|
+
// They are optimized for boyer-moore parsing.
|
220
|
+
var boundary = '--------------------------';
|
221
|
+
for (var i = 0; i < 24; i++) {
|
222
|
+
boundary += Math.floor(Math.random() * 10).toString(16);
|
223
|
+
}
|
224
|
+
|
225
|
+
this._boundary = boundary;
|
226
|
+
};
|
227
|
+
|
228
|
+
// Note: getLengthSync DOESN'T calculate streams length
|
229
|
+
// As workaround one can calculate file size manually
|
230
|
+
// and add it as knownLength option
|
231
|
+
FormData.prototype.getLengthSync = function(debug) {
|
232
|
+
var knownLength = this._overheadLength + this._valueLength;
|
233
|
+
|
234
|
+
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
235
|
+
// so it basically checks if there is any value added to the form
|
236
|
+
if (this._streams.length) {
|
237
|
+
knownLength += this._lastBoundary().length;
|
238
|
+
}
|
239
|
+
|
240
|
+
// https://github.com/felixge/node-form-data/issues/40
|
241
|
+
if (this._lengthRetrievers.length) {
|
242
|
+
// Some async length retrivers are present
|
243
|
+
// therefore synchronous length calculation is false.
|
244
|
+
// Please use getLength(callback) to get proper length
|
245
|
+
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
246
|
+
}
|
247
|
+
|
248
|
+
return knownLength;
|
249
|
+
};
|
250
|
+
|
251
|
+
FormData.prototype.getLength = function(cb) {
|
252
|
+
var knownLength = this._overheadLength + this._valueLength;
|
253
|
+
|
254
|
+
if (this._streams.length) {
|
255
|
+
knownLength += this._lastBoundary().length;
|
256
|
+
}
|
257
|
+
|
258
|
+
if (!this._lengthRetrievers.length) {
|
259
|
+
process.nextTick(cb.bind(this, null, knownLength));
|
260
|
+
return;
|
261
|
+
}
|
262
|
+
|
263
|
+
async.parallel(this._lengthRetrievers, function(err, values) {
|
264
|
+
if (err) {
|
265
|
+
cb(err);
|
266
|
+
return;
|
267
|
+
}
|
268
|
+
|
269
|
+
values.forEach(function(length) {
|
270
|
+
knownLength += length;
|
271
|
+
});
|
272
|
+
|
273
|
+
cb(null, knownLength);
|
274
|
+
});
|
275
|
+
};
|
276
|
+
|
277
|
+
FormData.prototype.submit = function(params, cb) {
|
278
|
+
|
279
|
+
var request
|
280
|
+
, options
|
281
|
+
, defaults = {
|
282
|
+
method : 'post'
|
283
|
+
};
|
284
|
+
|
285
|
+
// parse provided url if it's string
|
286
|
+
// or treat it as options object
|
287
|
+
if (typeof params == 'string') {
|
288
|
+
params = parseUrl(params);
|
289
|
+
|
290
|
+
options = populate({
|
291
|
+
port: params.port,
|
292
|
+
path: params.pathname,
|
293
|
+
host: params.hostname
|
294
|
+
}, defaults);
|
295
|
+
}
|
296
|
+
else // use custom params
|
297
|
+
{
|
298
|
+
options = populate(params, defaults);
|
299
|
+
// if no port provided use default one
|
300
|
+
if (!options.port) {
|
301
|
+
options.port = options.protocol == 'https:' ? 443 : 80;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
// put that good code in getHeaders to some use
|
306
|
+
options.headers = this.getHeaders(params.headers);
|
307
|
+
|
308
|
+
// https if specified, fallback to http in any other case
|
309
|
+
if (params.protocol == 'https:') {
|
310
|
+
request = https.request(options);
|
311
|
+
} else {
|
312
|
+
request = http.request(options);
|
313
|
+
}
|
314
|
+
|
315
|
+
// get content length and fire away
|
316
|
+
this.getLength(function(err, length) {
|
317
|
+
|
318
|
+
// TODO: Add chunked encoding when no length (if err)
|
319
|
+
|
320
|
+
// add content length
|
321
|
+
request.setHeader('Content-Length', length);
|
322
|
+
|
323
|
+
this.pipe(request);
|
324
|
+
if (cb) {
|
325
|
+
request.on('error', cb);
|
326
|
+
request.on('response', cb.bind(this, null));
|
327
|
+
}
|
328
|
+
}.bind(this));
|
329
|
+
|
330
|
+
return request;
|
331
|
+
};
|
332
|
+
|
333
|
+
FormData.prototype._error = function(err) {
|
334
|
+
if (this.error) return;
|
335
|
+
|
336
|
+
this.error = err;
|
337
|
+
this.pause();
|
338
|
+
this.emit('error', err);
|
339
|
+
};
|
340
|
+
|
341
|
+
/*
|
342
|
+
* Santa's little helpers
|
343
|
+
*/
|
344
|
+
|
345
|
+
// populates missing values
|
346
|
+
function populate(dst, src) {
|
347
|
+
for (var prop in src) {
|
348
|
+
if (!dst[prop]) dst[prop] = src[prop];
|
349
|
+
}
|
350
|
+
return dst;
|
351
|
+
}
|