Browse Source

convert method to uppercase in options

v5.x
Vsevolod Strukchinsky 9 years ago
parent
commit
9497e07506
  1. 6
      index.js
  2. 5
      test/redirects.js

6
index.js

@ -261,6 +261,8 @@ function normalizeArguments(url, opts) {
opts.method = opts.method || 'GET';
opts.method = opts.method.toUpperCase();
if (opts.hostname === 'unix') {
var matches = /(.+)\:(.+)/.exec(opts.path);
@ -320,7 +322,7 @@ helpers.forEach(function (el) {
opts = {};
}
return got(url, objectAssign({}, opts, {method: el.toUpperCase()}), cb);
return got(url, objectAssign({}, opts, {method: el}), cb);
};
});
@ -339,7 +341,7 @@ helpers.forEach(function (el) {
opts = {};
}
return got.stream(url, objectAssign({}, opts, {method: el.toUpperCase()}), cb);
return got.stream(url, objectAssign({}, opts, {method: el}), cb);
};
});

5
test/redirects.js

@ -78,6 +78,11 @@ test('redirect only GET and HEAD requests', async t => {
}
});
test('redirects works with lowercase method', async t => {
const body = (await got(`${s.url}/relative`, {method: 'head'})).body;
t.is(body, '');
});
test.after('cleanup', async t => {
await s.close();
});

Loading…
Cancel
Save