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 ruyadorno committed Nov 21, 2022
1 parent 1ce2f56 commit f208db7
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 @@ -173,8 +173,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 f208db7

Please sign in to comment.