diff --git a/index.js b/index.js index b8ccee0..bbd9e30 100644 --- a/index.js +++ b/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); }; }); diff --git a/test/redirects.js b/test/redirects.js index a723e8b..b023ed7 100644 --- a/test/redirects.js +++ b/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(); });