|
3 | 3 | const { |
4 | 4 | ArrayIsArray, |
5 | 5 | ArrayPrototypePush, |
6 | | - ObjectHasOwn, |
| 6 | + ArrayPrototypeSome, |
| 7 | + ObjectKeys, |
| 8 | + StringPrototypeToLowerCase, |
7 | 9 | Symbol, |
8 | 10 | SymbolAsyncIterator, |
9 | 11 | } = primordials; |
@@ -140,6 +142,12 @@ function parseHeaderPairs(pairs) { |
140 | 142 | const kGetHttp3Handle = Symbol('kGetHttp3Handle'); |
141 | 143 | const kSubmitInitialHeaders = Symbol('kSubmitInitialHeaders'); |
142 | 144 |
|
| 145 | +function hasPriorityHeader(headers) { |
| 146 | + return ArrayPrototypeSome( |
| 147 | + ObjectKeys(headers), |
| 148 | + (name) => StringPrototypeToLowerCase(name) === 'priority'); |
| 149 | +} |
| 150 | + |
143 | 151 | function priorityFieldValue(level, incremental) { |
144 | 152 | const urgency = level === 'high' ? 0 : level === 'low' ? 7 : 3; |
145 | 153 | if (urgency === 3 && !incremental) return undefined; |
@@ -254,6 +262,9 @@ class Http3Stream { |
254 | 262 | /** @type {Http3Session} */ |
255 | 263 | get session() { return this.#session; } |
256 | 264 |
|
| 265 | + /** @type {QuicStream} */ |
| 266 | + get stream() { return this.#stream; } |
| 267 | + |
257 | 268 | /** @type {bigint} */ |
258 | 269 | get id() { return this.#stream.id; } |
259 | 270 |
|
@@ -386,7 +397,7 @@ class Http3Stream { |
386 | 397 | if (!this.#isServer) { |
387 | 398 | const pri = priorityFieldValue( |
388 | 399 | this.#priority.level, this.#priority.incremental); |
389 | | - if (pri !== undefined && !ObjectHasOwn(headers, 'priority')) { |
| 400 | + if (pri !== undefined && !hasPriorityHeader(headers)) { |
390 | 401 | toSend = { __proto__: null, ...headers, priority: pri }; |
391 | 402 | } |
392 | 403 | } |
@@ -683,11 +694,18 @@ class Http3Session { |
683 | 694 | ...quicOptions |
684 | 695 | } = options; |
685 | 696 |
|
| 697 | + if (priority !== undefined) { |
| 698 | + validateOneOf(priority, 'options.priority', ['default', 'low', 'high']); |
| 699 | + } |
| 700 | + if (incremental !== undefined) { |
| 701 | + validateBoolean(incremental, 'options.incremental'); |
| 702 | + } |
| 703 | + |
686 | 704 | let headerString; |
687 | 705 | if (headers !== undefined) { |
688 | 706 | let toSend = headers; |
689 | 707 | const pri = priorityFieldValue(priority ?? 'default', incremental ?? false); |
690 | | - if (pri !== undefined && !ObjectHasOwn(headers, 'priority')) { |
| 708 | + if (pri !== undefined && !hasPriorityHeader(headers)) { |
691 | 709 | toSend = { __proto__: null, ...headers, priority: pri }; |
692 | 710 | } |
693 | 711 | headerString = buildNgHeaderString( |
|
0 commit comments