Skip to content

regression: empty/falsy ClientRequest method '' throws instead of defaulting to GET (over-validation from #4907) #4970

Description

@proggeramlug

Summary

Regression surfaced by re-measuring node:http parity on current main. test-http-client-defaults was fixed by #4904 (Agent/ClientRequest constructable), but the header-validation added in #4907 now over-fires on an empty/falsy method:

const req = new ClientRequest({ method: '', createConnection: () => {} });
assert.strictEqual(req.method, 'GET');   // Node defaults falsy method → 'GET'

Perry throws:

TypeError: Method must be a valid HTTP token [""]

Node treats a falsy method ('', undefined) as the default 'GET' — it does not validate-reject it. The validateHeaderName-style HTTP-token check from #4907 must only apply to a non-empty method; empty/falsy must fall through to the 'GET' default.

Repro

test-http-client-defaults.js (Node v22 test/parallel) — currently runtime-fail, was pass at the prior measurement.

Acceptance

new ClientRequest({ method: '' }) and ({ method: undefined }) default req.method to 'GET'; only a non-empty invalid token throws ERR_INVALID_HTTP_TOKEN. test-http-client-defaults back to pass, no re-break of #4907's validation tests.


Regression from #4907. Found re-measuring #2132's corpus on main (parity 26.2%).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions