Permalink
Browse files

Adding form-data support.

  • Loading branch information...
1 parent 6297612 commit 1f21b17fc4ff3a7011b23e3c9261d66effa3aa40 @mikeal mikeal committed Aug 29, 2012
Showing with 10,135 additions and 4 deletions.
  1. +14 βˆ’3 main.js
  2. +5 βˆ’0 node_modules/form-data/.npmignore
  3. +7 βˆ’0 node_modules/form-data/Makefile
  4. +86 βˆ’0 node_modules/form-data/Readme.md
  5. +237 βˆ’0 node_modules/form-data/lib/form_data.js
  6. +8 βˆ’0 node_modules/form-data/node-form-data.sublime-project
  7. +508 βˆ’0 node_modules/form-data/node-form-data.sublime-workspace
  8. +9 βˆ’0 node_modules/form-data/node_modules/async/.gitmodules
  9. +19 βˆ’0 node_modules/form-data/node_modules/async/LICENSE
  10. +21 βˆ’0 node_modules/form-data/node_modules/async/Makefile
  11. +970 βˆ’0 node_modules/form-data/node_modules/async/README.md
  12. BIN node_modules/form-data/node_modules/async/async.min.js.gzip
  13. +70 βˆ’0 node_modules/form-data/node_modules/async/deps/nodeunit.css
  14. +1,966 βˆ’0 node_modules/form-data/node_modules/async/deps/nodeunit.js
  15. +1 βˆ’0 node_modules/form-data/node_modules/async/dist/async.min.js
  16. +3 βˆ’0 node_modules/form-data/node_modules/async/index.js
  17. +632 βˆ’0 node_modules/form-data/node_modules/async/lib/async.js
  18. +4 βˆ’0 node_modules/form-data/node_modules/async/nodelint.cfg
  19. +41 βˆ’0 node_modules/form-data/node_modules/async/package.json
  20. BIN node_modules/form-data/node_modules/async/test/.swp
  21. +1,367 βˆ’0 node_modules/form-data/node_modules/async/test/test-async.js
  22. +24 βˆ’0 node_modules/form-data/node_modules/async/test/test.html
  23. +3 βˆ’0 node_modules/form-data/node_modules/combined-stream/.npmignore
  24. +19 βˆ’0 node_modules/form-data/node_modules/combined-stream/License
  25. +7 βˆ’0 node_modules/form-data/node_modules/combined-stream/Makefile
  26. +132 βˆ’0 node_modules/form-data/node_modules/combined-stream/Readme.md
  27. +183 βˆ’0 node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js
  28. +2 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore
  29. +19 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License
  30. +7 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile
  31. +154 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md
  32. +99 βˆ’0 ..._modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js
  33. +38 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json
  34. +6 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js
  35. +38 βˆ’0 ..._modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js
  36. +21 βˆ’0 ...es/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js
  37. +14 βˆ’0 ...modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js
  38. +48 βˆ’0 .../node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
  39. +15 βˆ’0 ...modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js
  40. +18 βˆ’0 ...a/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js
  41. +13 βˆ’0 ...ta/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js
  42. +13 βˆ’0 .../node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js
  43. +7 βˆ’0 node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js
  44. +39 βˆ’0 node_modules/form-data/node_modules/combined-stream/package.json
  45. +12 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/common.js
  46. +256 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/fixture/file1.txt
  47. +256 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/fixture/file2.txt
  48. +27 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/integration/test-callback-streams.js
  49. +34 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/integration/test-data-size.js
  50. +38 βˆ’0 ...ata/node_modules/combined-stream/test/integration/test-delayed-streams-and-buffers-and-strings.js
  51. +35 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/integration/test-delayed-streams.js
  52. +24 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/integration/test-max-data-size.js
  53. +30 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/integration/test-unpaused-streams.js
  54. +7 βˆ’0 node_modules/form-data/node_modules/combined-stream/test/run.js
  55. +43 βˆ’0 node_modules/form-data/package.json
  56. +14 βˆ’0 node_modules/form-data/test/common.js
  57. +1 βˆ’0 node_modules/form-data/test/fixture/bacon.txt
  58. BIN node_modules/form-data/test/fixture/unicycle.jpg
  59. +93 βˆ’0 node_modules/form-data/test/integration/test-form-get-length.js
  60. +18 βˆ’0 node_modules/form-data/test/integration/test-get-boundary.js
  61. +121 βˆ’0 node_modules/form-data/test/integration/test-http-response.js
  62. +111 βˆ’0 node_modules/form-data/test/integration/test-pipe.js
  63. +107 βˆ’0 node_modules/form-data/test/integration/test-submit.js
  64. +7 βˆ’0 node_modules/form-data/test/run.js
  65. +19 βˆ’0 node_modules/mime/LICENSE
  66. +63 βˆ’0 node_modules/mime/README.md
  67. +104 βˆ’0 node_modules/mime/mime.js
  68. +42 βˆ’0 node_modules/mime/package.json
  69. +55 βˆ’0 node_modules/mime/test.js
  70. +1,588 βˆ’0 node_modules/mime/types/mime.types
  71. +59 βˆ’0 node_modules/mime/types/node.types
  72. +2 βˆ’1 package.json
  73. +3 βˆ’0 tests/run.js
  74. +79 βˆ’0 tests/test-form.js
  75. BIN tests/unicycle.jpg
View
17 main.js
@@ -28,6 +28,8 @@ var http = require('http')
, cookieJar = new CookieJar
, tunnel = require('./tunnel')
, aws = require('./aws')
+
+ , FormData = require('form-data')
;
if (process.logging) {
@@ -344,6 +346,10 @@ Request.prototype.init = function (options) {
process.nextTick(function () {
if (self._aborted) return
+ if (self._form) {
+ self.setHeaders(self._form.getHeaders())
+ self._form.pipe(self)
+ }
if (self.body) {
if (Array.isArray(self.body)) {
self.body.forEach(function (part) {
@@ -723,9 +729,14 @@ Request.prototype.qs = function (q, clobber) {
return this
}
Request.prototype.form = function (form) {
- this.headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
- this.body = qs.stringify(form).toString('utf8')
- return this
+ if (form) {
+ this.headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
+ this.body = qs.stringify(form).toString('utf8')
+ return this
+ }
+ // create form-data object
+ this._form = new FormData()
+ return this._form
}
Request.prototype.multipart = function (multipart) {
var self = this

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

1 comment on commit 1f21b17

zzen commented on 1f21b17 Aug 31, 2012

Ever since this commit I cannot get request to install properly as a dependecy:

  Error: Cannot find module 'mime'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)

Tested both on node 0.8.7 with npm 1.1.49 and node 0.6.18 with npm 1.1.21

I should add that going into the package dir and installing mime and form-data manually solves the problem. Seems to me to be problem with bundleDependencies declarations

Please sign in to comment.