diff --git a/index.js b/index.js index a66003f..2081c58 100644 --- a/index.js +++ b/index.js @@ -243,6 +243,8 @@ function normalizeArguments(url, opts) { opts.method = opts.method || 'GET'; + opts.method = opts.method.toUpperCase(); + if (opts.hostname === 'unix') { const matches = /(.+)\:(.+)/.exec(opts.path); @@ -286,7 +288,7 @@ const helpers = [ ]; helpers.forEach(el => { - got[el] = (url, opts) => got(url, Object.assign({}, opts, {method: el.toUpperCase()})); + got[el] = (url, opts) => got(url, Object.assign({}, opts, {method: el})); }); got.stream = function (url, opts) { @@ -295,7 +297,7 @@ got.stream = function (url, opts) { helpers.forEach(el => { got.stream[el] = function (url, opts) { - return got.stream(url, Object.assign({}, opts, {method: el.toUpperCase()})); + return got.stream(url, Object.assign({}, opts, {method: el})); }; }); diff --git a/test/post.js b/test/post.js index d2cd97a..16412c6 100644 --- a/test/post.js +++ b/test/post.js @@ -109,6 +109,11 @@ test('content-type header is not overriden when object in options.body', async t t.is(body['content-type'], 'doge'); }); +test('transforms method to uppercase', async t => { + const headers = (await got(s.url, {method: 'get'})).headers; + t.is(headers.method, 'GET'); +}); + test.after('cleanup', async () => { await s.close(); });