| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3833fce commit 157bd07
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -300,11 +300,12 @@ function onStreamCloseRequest() { | |||
| 300 | 300 | req.emit('close'); | |
| 301 | 301 | } | |
| 302 | 302 | ||
| 303 | - function onStreamTimeout(kind) { | ||
| 304 | - return function onStreamTimeout() { | ||
| 305 | - const obj = this[kind]; | ||
| 306 | - obj.emit('timeout'); | ||
| 307 | - }; | ||
| 303 | + function onStreamTimeoutRequest() { | ||
| 304 | + this[kRequest].emit('timeout'); | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + function onStreamTimeoutResponse() { | ||
| 308 | + this[kResponse].emit('timeout'); | ||
| 308 | 309 | } | |
| 309 | 310 | ||
| 310 | 311 | class Http2ServerRequest extends Readable { | |
@@ -332,7 +333,7 @@ class Http2ServerRequest extends Readable { | |||
| 332 | 333 | stream.on('error', onStreamError); | |
| 333 | 334 | stream.on('aborted', onStreamAbortedRequest); | |
| 334 | 335 | stream.on('close', onStreamCloseRequest); | |
| 335 | - stream.on('timeout', onStreamTimeout(kRequest)); | ||
| 336 | + stream.on('timeout', onStreamTimeoutRequest); | ||
| 336 | 337 | this.on('pause', onRequestPause); | |
| 337 | 338 | this.on('resume', onRequestResume); | |
| 338 | 339 | } | |
@@ -486,7 +487,7 @@ class Http2ServerResponse extends Stream { | |||
| 486 | 487 | stream.on('aborted', onStreamAbortedResponse); | |
| 487 | 488 | stream.on('close', onStreamCloseResponse); | |
| 488 | 489 | stream.on('wantTrailers', onStreamTrailersReady); | |
| 489 | - stream.on('timeout', onStreamTimeout(kResponse)); | ||
| 490 | + stream.on('timeout', onStreamTimeoutResponse); | ||
| 490 | 491 | } | |
| 491 | 492 | ||
| 492 | 493 | // User land modules such as finalhandler just check truthiness of this | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -770,14 +770,16 @@ function buildNgHeaderString(arrayOrMap, | |||
| 770 | 770 | let pseudoHeaders = ''; | |
| 771 | 771 | let count = 0; | |
| 772 | 772 | ||
| 773 | - const singles = new SafeSet(); | ||
| 773 | + let singles; | ||
| 774 | 774 | const sensitiveHeaders = arrayOrMap[kSensitiveHeaders] || emptyArray; | |
| 775 | - const neverIndex = sensitiveHeaders.map((v) => v.toLowerCase()); | ||
| 775 | + const neverIndex = sensitiveHeaders.length === 0 ? | ||
| 776 | + emptyArray : sensitiveHeaders.map((v) => v.toLowerCase()); | ||
| 776 | 777 | ||
| 777 | 778 | function processHeader(key, value) { | |
| 778 | 779 | key = key.toLowerCase(); | |
| 780 | + const isSingleValueField = kSingleValueFields.has(key); | ||
| 779 | 781 | const isStrictSingleValueField = strictSingleValueFields && | |
| 780 | - kSingleValueFields.has(key); | ||
| 782 | + isSingleValueField; | ||
| 781 | 783 | let isArray = ArrayIsArray(value); | |
| 782 | 784 | if (isArray) { | |
| 783 | 785 | switch (value.length) { | |
@@ -795,11 +797,15 @@ function buildNgHeaderString(arrayOrMap, | |||
| 795 | 797 | value = String(value); | |
| 796 | 798 | } | |
| 797 | 799 | if (isStrictSingleValueField) { | |
| 798 | - if (singles.has(key)) | ||
| 800 | + if (singles === undefined) { | ||
| 801 | + singles = [key]; | ||
| 802 | + } else if (singles.includes(key)) { | ||
| 799 | 803 | throw new ERR_HTTP2_HEADER_SINGLE_VALUE(key); | |
| 800 | - singles.add(key); | ||
| 804 | + } else { | ||
| 805 | + singles.push(key); | ||
| 806 | + } | ||
| 801 | 807 | } | |
| 802 | - const flags = neverIndex.includes(key) ? | ||
| 808 | + const flags = neverIndex.length !== 0 && neverIndex.includes(key) ? | ||
| 803 | 809 | kNeverIndexFlag : | |
| 804 | 810 | kNoHeaderFlags; | |
| 805 | 811 | if (key[0] === ':') { | |
@@ -810,11 +816,15 @@ function buildNgHeaderString(arrayOrMap, | |||
| 810 | 816 | count++; | |
| 811 | 817 | return; | |
| 812 | 818 | } | |
| 813 | - if (!checkIsHttpToken(key)) { | ||
| 814 | - throw new ERR_INVALID_HTTP_TOKEN('Header name', key); | ||
| 815 | - } | ||
| 816 | - if (isIllegalConnectionSpecificHeader(key, value)) { | ||
| 817 | - throw new ERR_HTTP2_INVALID_CONNECTION_HEADERS(key); | ||
| 819 | + // Well-known single-value fields are all valid HTTP tokens and none of | ||
| 820 | + // them is a connection-specific header, so both checks can be skipped. | ||
| 821 | + if (!isSingleValueField) { | ||
| 822 | + if (!checkIsHttpToken(key)) { | ||
| 823 | + throw new ERR_INVALID_HTTP_TOKEN('Header name', key); | ||
| 824 | + } | ||
| 825 | + if (isIllegalConnectionSpecificHeader(key, value)) { | ||
| 826 | + throw new ERR_HTTP2_INVALID_CONNECTION_HEADERS(key); | ||
| 827 | + } | ||
| 818 | 828 | } | |
| 819 | 829 | if (isArray) { | |
| 820 | 830 | for (let j = 0; j < value.length; ++j) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments