ai 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -24
- package/dist/ai-stream.d.ts +18 -0
- package/dist/ai-stream.js +132 -0
- package/dist/ai-stream.mjs +13 -0
- package/dist/anthropic-stream.d.ts +5 -0
- package/dist/anthropic-stream.js +133 -0
- package/dist/anthropic-stream.mjs +8 -0
- package/dist/chunk-265FSSO4.mjs +91 -0
- package/dist/chunk-2L3ZO4UM.mjs +45 -0
- package/dist/chunk-GT4HKF2X.mjs +33 -0
- package/dist/chunk-JGDC3BXD.mjs +22 -0
- package/dist/chunk-NK2CVBLI.mjs +38 -0
- package/dist/chunk-PEYAHBDF.mjs +43 -0
- package/dist/chunk-TJMME6CL.mjs +24 -0
- package/dist/huggingface-stream.d.ts +5 -0
- package/dist/huggingface-stream.js +121 -0
- package/dist/huggingface-stream.mjs +8 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +278 -0
- package/dist/index.mjs +35 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.js +12 -0
- package/dist/index.test.mjs +10 -0
- package/dist/langchain-stream.d.ts +12 -0
- package/dist/langchain-stream.js +102 -0
- package/dist/langchain-stream.mjs +8 -0
- package/dist/openai-stream.d.ts +5 -0
- package/dist/openai-stream.js +144 -0
- package/dist/openai-stream.mjs +8 -0
- package/dist/streaming-text-response.d.ts +17 -0
- package/dist/streaming-text-response.js +75 -0
- package/dist/streaming-text-response.mjs +9 -0
- package/package.json +78 -29
- package/react/dist/chunk-5PP6W52J.mjs +202 -0
- package/react/dist/chunk-6EH3SWMP.mjs +55 -0
- package/react/dist/chunk-PW6HSU2N.mjs +154 -0
- package/react/dist/index.d.ts +3 -0
- package/react/dist/index.js +424 -0
- package/react/dist/index.mjs +12 -0
- package/react/dist/types-f862f74a.d.ts +123 -0
- package/react/dist/use-chat.d.ts +42 -0
- package/react/dist/use-chat.js +276 -0
- package/react/dist/use-chat.mjs +8 -0
- package/react/dist/use-completion.d.ts +47 -0
- package/react/dist/use-completion.js +229 -0
- package/react/dist/use-completion.mjs +8 -0
- package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
- package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
- package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
- package/svelte/dist/index.d.ts +4 -0
- package/svelte/dist/index.js +808 -0
- package/svelte/dist/index.mjs +11 -0
- package/svelte/dist/types-f862f74a.d.ts +123 -0
- package/svelte/dist/use-chat.d.ts +39 -0
- package/svelte/dist/use-chat.js +680 -0
- package/svelte/dist/use-chat.mjs +7 -0
- package/svelte/dist/use-completion.d.ts +38 -0
- package/svelte/dist/use-completion.js +640 -0
- package/svelte/dist/use-completion.mjs +7 -0
- package/.npmignore +0 -15
- package/.travis.yml +0 -4
- package/README.md +0 -21
- package/bin/ai.js +0 -22
- package/index.js +0 -37
- package/node_modules/request/.npmignore +0 -2
- package/node_modules/request/.travis.yml +0 -12
- package/node_modules/request/CHANGELOG.md +0 -954
- package/node_modules/request/LICENSE +0 -55
- package/node_modules/request/README.md +0 -421
- package/node_modules/request/index.js +0 -166
- package/node_modules/request/lib/cookies.js +0 -40
- package/node_modules/request/lib/copy.js +0 -8
- package/node_modules/request/lib/debug.js +0 -7
- package/node_modules/request/lib/getSafe.js +0 -34
- package/node_modules/request/lib/optional.js +0 -5
- package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
- package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
- package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
- package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
- package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/forever-agent/README.md +0 -4
- package/node_modules/request/node_modules/forever-agent/index.js +0 -119
- package/node_modules/request/node_modules/forever-agent/package.json +0 -46
- package/node_modules/request/node_modules/form-data/License +0 -19
- package/node_modules/request/node_modules/form-data/Readme.md +0 -175
- package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
- package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
- package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
- package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
- package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
- package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
- package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
- package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
- package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
- package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
- package/node_modules/request/node_modules/form-data/package.json +0 -80
- package/node_modules/request/node_modules/hawk/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/README.md +0 -625
- package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
- package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
- package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
- package/node_modules/request/node_modules/hawk/index.js +0 -1
- package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
- package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
- package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
- package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
- package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
- package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
- package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
- package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
- package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
- package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
- package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
- package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
- package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
- package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
- package/node_modules/request/node_modules/hawk/package.json +0 -70
- package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
- package/node_modules/request/node_modules/hawk/test/client.js +0 -206
- package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
- package/node_modules/request/node_modules/hawk/test/index.js +0 -316
- package/node_modules/request/node_modules/hawk/test/message.js +0 -246
- package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
- package/node_modules/request/node_modules/hawk/test/server.js +0 -686
- package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
- package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
- package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
- package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
- package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
- package/node_modules/request/node_modules/http-signature/README.md +0 -75
- package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
- package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
- package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
- package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
- package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
- package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
- package/node_modules/request/node_modules/http-signature/package.json +0 -54
- package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
- package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
- package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
- package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
- package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
- package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
- package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
- package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
- package/node_modules/request/node_modules/mime-types/Makefile +0 -9
- package/node_modules/request/node_modules/mime-types/README.md +0 -101
- package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
- package/node_modules/request/node_modules/mime-types/component.json +0 -16
- package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
- package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
- package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
- package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
- package/node_modules/request/node_modules/mime-types/package.json +0 -69
- package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
- package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
- package/node_modules/request/node_modules/node-uuid/README.md +0 -207
- package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
- package/node_modules/request/node_modules/node-uuid/component.json +0 -18
- package/node_modules/request/node_modules/node-uuid/package.json +0 -54
- package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
- package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
- package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
- package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
- package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
- package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
- package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
- package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
- package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
- package/node_modules/request/node_modules/qs/.jshintignore +0 -1
- package/node_modules/request/node_modules/qs/.jshintrc +0 -10
- package/node_modules/request/node_modules/qs/.npmignore +0 -18
- package/node_modules/request/node_modules/qs/.travis.yml +0 -4
- package/node_modules/request/node_modules/qs/LICENSE +0 -28
- package/node_modules/request/node_modules/qs/Makefile +0 -8
- package/node_modules/request/node_modules/qs/Readme.md +0 -120
- package/node_modules/request/node_modules/qs/index.js +0 -1
- package/node_modules/request/node_modules/qs/lib/index.js +0 -15
- package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
- package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
- package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
- package/node_modules/request/node_modules/qs/package.json +0 -61
- package/node_modules/request/node_modules/qs/test/parse.js +0 -236
- package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
- package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
- package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
- package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
- package/node_modules/request/node_modules/stringstream/README.md +0 -38
- package/node_modules/request/node_modules/stringstream/example.js +0 -27
- package/node_modules/request/node_modules/stringstream/package.json +0 -48
- package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
- package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
- package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
- package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
- package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
- package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
- package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
- package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
- package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
- package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
- package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
- package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
- package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
- package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
- package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
- package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
- package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
- package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
- package/node_modules/request/package.json +0 -77
- package/node_modules/request/request.js +0 -1428
- package/test/fixtures/github-response.json +0 -1367
- package/test/index.js +0 -55
@@ -1,175 +0,0 @@
|
|
1
|
-
# Form-Data [](https://travis-ci.org/felixge/node-form-data) [](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.
|
@@ -1,351 +0,0 @@
|
|
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
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2010-2014 Caolan McMahon
|
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.
|