explicit POST and comment on possible deviation from request API

This commit is contained in:
AJ ONeal 2018-07-06 22:40:28 -06:00
parent aa509ea4ce
commit c355fb20c4
3 changed files with 5 additions and 3 deletions

View File

@ -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'))

View File

@ -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' }
}

View File

@ -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();