Skip to content

Commit

Permalink
http: add debug log for ERR_UNESCAPED_CHARACTERS
Browse files Browse the repository at this point in the history
When encountering ERR_UNESCAPED_CHARACTERS on large applications it can
be unclear which request has caused this error. Even when setting
NODE_DEBUG=http there is no information about this error since it's
thrown before any debug logs. This patch adds a debug log that contains
the invalid path.

PR-URL: #45420
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
aidant authored and danielleadams committed Jan 3, 2023
1 parent f2a4def commit 209e7e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ function ClientRequest(input, options, cb) {

if (options.path) {
const path = String(options.path);
if (RegExpPrototypeExec(INVALID_PATH_REGEX, path) !== null)
if (RegExpPrototypeExec(INVALID_PATH_REGEX, path) !== null) {
debug('Path contains unescaped characters: "%s"', path);
throw new ERR_UNESCAPED_CHARACTERS('Request path');
}
}

if (protocol !== expectedProtocol) {
Expand Down

0 comments on commit 209e7e3

Please sign in to comment.