| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8cf8a32 commit 6583016
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -711,7 +711,7 @@ requests and responses. | |||
| 711 | 711 | <a id="ERR_HTTP2_INVALID_HEADER_VALUE"></a> | |
| 712 | 712 | ### ERR_HTTP2_INVALID_HEADER_VALUE | |
| 713 | 713 | ||
| 714 | - Used to indicate that an invalid HTTP/2 header value has been specified. | ||
| 714 | + Used to indicate that an invalid HTTP2 header value has been specified. | ||
| 715 | 715 | ||
| 716 | 716 | <a id="ERR_HTTP2_INVALID_INFO_STATUS"></a> | |
| 717 | 717 | ### ERR_HTTP2_INVALID_INFO_STATUS | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -185,7 +185,7 @@ E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED', | |||
| 185 | 185 | 'Informational status codes cannot be used'); | |
| 186 | 186 | E('ERR_HTTP2_INVALID_CONNECTION_HEADERS', | |
| 187 | 187 | 'HTTP/1 Connection specific headers are forbidden: "%s"'); | |
| 188 | - E('ERR_HTTP2_INVALID_HEADER_VALUE', 'Value must not be undefined or null'); | ||
| 188 | + E('ERR_HTTP2_INVALID_HEADER_VALUE', 'Invalid value "%s" for header "%s"'); | ||
| 189 | 189 | E('ERR_HTTP2_INVALID_INFO_STATUS', | |
| 190 | 190 | (code) => `Invalid informational status code: ${code}`); | |
| 191 | 191 | E('ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,12 +40,18 @@ let statusMessageWarned = false; | |||
| 40 | 40 | // close as possible to the current require('http') API | |
| 41 | 41 | ||
| 42 | 42 | function assertValidHeader(name, value) { | |
| 43 | - if (name === '' || typeof name !== 'string') | ||
| 44 | - throw new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name); | ||
| 45 | - if (isPseudoHeader(name)) | ||
| 46 | - throw new errors.Error('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED'); | ||
| 47 | - if (value === undefined || value === null) | ||
| 48 | - throw new errors.TypeError('ERR_HTTP2_INVALID_HEADER_VALUE'); | ||
| 43 | + let err; | ||
| 44 | + if (name === '' || typeof name !== 'string') { | ||
| 45 | + err = new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name); | ||
| 46 | + } else if (isPseudoHeader(name)) { | ||
| 47 | + err = new errors.Error('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED'); | ||
| 48 | + } else if (value === undefined || value === null) { | ||
| 49 | + err = new errors.TypeError('ERR_HTTP2_INVALID_HEADER_VALUE', value, name); | ||
| 50 | + } | ||
| 51 | + if (err !== undefined) { | ||
| 52 | + Error.captureStackTrace(err, assertValidHeader); | ||
| 53 | + throw err; | ||
| 54 | + } | ||
| 49 | 55 | } | |
| 50 | 56 | ||
| 51 | 57 | function isPseudoHeader(name) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,14 +85,14 @@ server.listen(0, common.mustCall(function() { | |||
| 85 | 85 | }, common.expectsError({ | |
| 86 | 86 | code: 'ERR_HTTP2_INVALID_HEADER_VALUE', | |
| 87 | 87 | type: TypeError, | |
| 88 | - message: 'Value must not be undefined or null' | ||
| 88 | + message: 'Invalid value "null" for header "foo-bar"' | ||
| 89 | 89 | })); | |
| 90 | 90 | assert.throws(function() { | |
| 91 | 91 | response.setHeader(real, undefined); | |
| 92 | 92 | }, common.expectsError({ | |
| 93 | 93 | code: 'ERR_HTTP2_INVALID_HEADER_VALUE', | |
| 94 | 94 | type: TypeError, | |
| 95 | - message: 'Value must not be undefined or null' | ||
| 95 | + message: 'Invalid value "undefined" for header "foo-bar"' | ||
| 96 | 96 | })); | |
| 97 | 97 | common.expectsError( | |
| 98 | 98 | () => response.setHeader(), // header name undefined | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,15 +28,15 @@ server.listen(0, common.mustCall(() => { | |||
| 28 | 28 | { | |
| 29 | 29 | code: 'ERR_HTTP2_INVALID_HEADER_VALUE', | |
| 30 | 30 | type: TypeError, | |
| 31 | - message: 'Value must not be undefined or null' | ||
| 31 | + message: 'Invalid value "undefined" for header "test"' | ||
| 32 | 32 | } | |
| 33 | 33 | ); | |
| 34 | 34 | common.expectsError( | |
| 35 | 35 | () => response.setTrailer('test', null), | |
| 36 | 36 | { | |
| 37 | 37 | code: 'ERR_HTTP2_INVALID_HEADER_VALUE', | |
| 38 | 38 | type: TypeError, | |
| 39 | - message: 'Value must not be undefined or null' | ||
| 39 | + message: 'Invalid value "null" for header "test"' | ||
| 40 | 40 | } | |
| 41 | 41 | ); | |
| 42 | 42 | common.expectsError( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments