diff --git a/lib/_http_client.js b/lib/_http_client.js index f5d3d711a7f..63a7befc8eb 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -80,6 +80,7 @@ const { const { validateInteger, validateBoolean, + validateString, } = require('internal/validators'); const { getTimerDuration } = require('internal/timers'); const { @@ -270,12 +271,11 @@ function ClientRequest(input, options, cb) { delete optsWithoutSignal.signal; } let method = options.method; - const methodIsString = (typeof method === 'string'); - if (method !== null && method !== undefined && !methodIsString) { - throw new ERR_INVALID_ARG_TYPE('options.method', 'string', method); + if (method != null) { + validateString(method, 'options.method'); } - if (methodIsString && method) { + if (method) { if (!checkIsHttpToken(method)) { throw new ERR_INVALID_HTTP_TOKEN('Method', method); }