-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
http: refactor to use validateHeaderName
#46143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -628,9 +628,9 @@ function matchHeader(self, state, field, value) { | |
| } | ||
| } | ||
|
|
||
| const validateHeaderName = hideStackFrames((name) => { | ||
| const validateHeaderName = hideStackFrames((name, label = 'Header name') => { | ||
|
||
| if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) { | ||
| throw new ERR_INVALID_HTTP_TOKEN('Header name', name); | ||
| throw new ERR_INVALID_HTTP_TOKEN(label, name); | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -933,9 +933,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { | |
| field = key; | ||
| value = headers[key]; | ||
| } | ||
| if (typeof field !== 'string' || !field || !checkIsHttpToken(field)) { | ||
| throw new ERR_INVALID_HTTP_TOKEN('Trailer name', field); | ||
| } | ||
| validateHeaderName(field, 'Trailer name'); | ||
|
|
||
| // Check if the field must be sent several times | ||
| const isArrayValue = ArrayIsArray(value); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.