diff --git a/examples/form-data.js b/examples/form-data.js index 59d2f1d..aeedab7 100644 --- a/examples/form-data.js +++ b/examples/form-data.js @@ -10,9 +10,8 @@ var request = require('../'); request( //{ url: 'http://postb.in/syfxxnko' { url: 'http://localhost:3007/form-data/' - , headers: { - 'X-Foo': 'Bar' - } + , method: 'POST' + , headers: { 'X-Foo': 'Bar' } , formData: { foo: 'bar' , baz: require('fs').createReadStream(require('path').join(__dirname, 'get-to-json.js')) diff --git a/examples/www-form.js b/examples/www-form.js index 9b40991..045c29f 100644 --- a/examples/www-form.js +++ b/examples/www-form.js @@ -9,6 +9,7 @@ var request = require('../'); //request('http://www.github.com', function (error, response, body) { request( { url: 'http://postb.in/2meyt50C' + , method: 'POST' , headers: { 'X-Foo': 'Bar' } , form: { foo: 'bar', baz: 'qux' } } diff --git a/index.js b/index.js index 80fc3c8..06aaff0 100644 --- a/index.js +++ b/index.js @@ -343,6 +343,8 @@ function setDefaults(defs) { } if (opts.body || 'string' === typeof opts.json || opts.form || opts.formData) { + // TODO this is probably a deviation from request's API + // need to check and probably eliminate it reqOpts.method = (reqOpts.method || 'POST').toUpperCase(); } else { reqOpts.method = (reqOpts.method || 'GET').toUpperCase();