explicit POST and comment on possible deviation from request API
This commit is contained in:
parent
aa509ea4ce
commit
c355fb20c4
|
@ -10,9 +10,8 @@ var request = require('../');
|
||||||
request(
|
request(
|
||||||
//{ url: 'http://postb.in/syfxxnko'
|
//{ url: 'http://postb.in/syfxxnko'
|
||||||
{ url: 'http://localhost:3007/form-data/'
|
{ url: 'http://localhost:3007/form-data/'
|
||||||
, headers: {
|
, method: 'POST'
|
||||||
'X-Foo': 'Bar'
|
, headers: { 'X-Foo': 'Bar' }
|
||||||
}
|
|
||||||
, formData: {
|
, formData: {
|
||||||
foo: 'bar'
|
foo: 'bar'
|
||||||
, baz: require('fs').createReadStream(require('path').join(__dirname, 'get-to-json.js'))
|
, baz: require('fs').createReadStream(require('path').join(__dirname, 'get-to-json.js'))
|
||||||
|
|
|
@ -9,6 +9,7 @@ var request = require('../');
|
||||||
//request('http://www.github.com', function (error, response, body) {
|
//request('http://www.github.com', function (error, response, body) {
|
||||||
request(
|
request(
|
||||||
{ url: 'http://postb.in/2meyt50C'
|
{ url: 'http://postb.in/2meyt50C'
|
||||||
|
, method: 'POST'
|
||||||
, headers: { 'X-Foo': 'Bar' }
|
, headers: { 'X-Foo': 'Bar' }
|
||||||
, form: { foo: 'bar', baz: 'qux' }
|
, form: { foo: 'bar', baz: 'qux' }
|
||||||
}
|
}
|
||||||
|
|
2
index.js
2
index.js
|
@ -343,6 +343,8 @@ function setDefaults(defs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.body || 'string' === typeof opts.json || opts.form || opts.formData) {
|
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();
|
reqOpts.method = (reqOpts.method || 'POST').toUpperCase();
|
||||||
} else {
|
} else {
|
||||||
reqOpts.method = (reqOpts.method || 'GET').toUpperCase();
|
reqOpts.method = (reqOpts.method || 'GET').toUpperCase();
|
||||||
|
|
Loading…
Reference in New Issue