Skip to content

Commit 163c2db

Browse files
committed
quic: move HTTP/3 protocol machinery into node:http3
Move nghttp3 integration, and header/priority/settings/datagram-framing logic out of node:quic core into node:http3, leaving node:quic as a pure transport-only layer.
1 parent 32ff1bc commit 163c2db

33 files changed

Lines changed: 2019 additions & 1750 deletions

lib/internal/quic/http3.js

Lines changed: 526 additions & 34 deletions
Large diffs are not rendered by default.

lib/internal/quic/quic.js

Lines changed: 83 additions & 693 deletions
Large diffs are not rendered by default.

lib/internal/quic/state.js

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ const {
7171
IDX_STATE_SESSION_HANDSHAKE_CONFIRMED,
7272
IDX_STATE_SESSION_STREAM_OPEN_ALLOWED,
7373
IDX_STATE_SESSION_PRIORITY_SUPPORTED,
74-
IDX_STATE_SESSION_HEADERS_SUPPORTED,
7574
IDX_STATE_SESSION_WRAPPED,
76-
IDX_STATE_SESSION_APPLICATION_TYPE,
75+
IDX_STATE_SESSION_IS_SERVER,
76+
IDX_STATE_SESSION_HAS_APPLICATION,
7777
IDX_STATE_SESSION_NO_ERROR_CODE,
7878
IDX_STATE_SESSION_INTERNAL_ERROR_CODE,
7979
IDX_STATE_SESSION_MAX_DATAGRAM_SIZE,
@@ -117,9 +117,9 @@ assert(IDX_STATE_SESSION_HANDSHAKE_COMPLETED !== undefined);
117117
assert(IDX_STATE_SESSION_HANDSHAKE_CONFIRMED !== undefined);
118118
assert(IDX_STATE_SESSION_STREAM_OPEN_ALLOWED !== undefined);
119119
assert(IDX_STATE_SESSION_PRIORITY_SUPPORTED !== undefined);
120-
assert(IDX_STATE_SESSION_HEADERS_SUPPORTED !== undefined);
120+
assert(IDX_STATE_SESSION_HAS_APPLICATION !== undefined);
121+
assert(IDX_STATE_SESSION_IS_SERVER !== undefined);
121122
assert(IDX_STATE_SESSION_WRAPPED !== undefined);
122-
assert(IDX_STATE_SESSION_APPLICATION_TYPE !== undefined);
123123
assert(IDX_STATE_SESSION_NO_ERROR_CODE !== undefined);
124124
assert(IDX_STATE_SESSION_INTERNAL_ERROR_CODE !== undefined);
125125
assert(IDX_STATE_SESSION_MAX_DATAGRAM_SIZE !== undefined);
@@ -349,7 +349,6 @@ class QuicSessionState {
349349
static #LISTENER_SESSION_TICKET = 1 << 3;
350350
static #LISTENER_NEW_TOKEN = 1 << 4;
351351
static #LISTENER_ORIGIN = 1 << 5;
352-
static #LISTENER_APPLICATION = 1 << 6;
353352

354353
#getListenerFlag(flag) {
355354
const handle = this.#handle;
@@ -368,13 +367,6 @@ class QuicSessionState {
368367
val ? (current | flag) : (current & ~flag), kIsLittleEndian);
369368
}
370369

371-
/** @type {boolean} */
372-
get hasApplicationListener() {
373-
return this.#getListenerFlag(QuicSessionState.#LISTENER_APPLICATION);
374-
}
375-
set hasApplicationListener(val) {
376-
this.#setListenerFlag(QuicSessionState.#LISTENER_APPLICATION, val);
377-
}
378370

379371
/** @type {boolean} */
380372
get hasPathValidationListener() {
@@ -481,14 +473,14 @@ class QuicSessionState {
481473
}
482474

483475
/**
484-
* Whether the negotiated application protocol supports headers.
485-
* Returns 0 (unknown), 1 (supported), or 2 (not supported).
486-
* @type {number}
476+
* Whether a protocol application (vs the native raw-stream path) is
477+
* installed on the session.
478+
* @type {boolean}
487479
*/
488-
get headersSupported() {
480+
get hasApplication() {
489481
const handle = this.#handle;
490482
if (handle === undefined) return undefined;
491-
return DataViewPrototypeGetUint8(handle, this.#offset + IDX_STATE_SESSION_HEADERS_SUPPORTED);
483+
return DataViewPrototypeGetUint8(handle, this.#offset + IDX_STATE_SESSION_HAS_APPLICATION) !== 0;
492484
}
493485

494486
/** @type {boolean} */
@@ -498,17 +490,21 @@ class QuicSessionState {
498490
return DataViewPrototypeGetUint8(handle, this.#offset + IDX_STATE_SESSION_WRAPPED) !== 0;
499491
}
500492

501-
/** @type {number} */
502-
get applicationType() {
493+
/**
494+
* True for server (accepted) sessions, false for client (initiated)
495+
* sessions. Fixed for the session's lifetime.
496+
* @type {boolean}
497+
*/
498+
get isServer() {
503499
const handle = this.#handle;
504500
if (handle === undefined) return undefined;
505-
return DataViewPrototypeGetUint8(handle, this.#offset + IDX_STATE_SESSION_APPLICATION_TYPE);
501+
return DataViewPrototypeGetUint8(handle, this.#offset + IDX_STATE_SESSION_IS_SERVER) !== 0;
506502
}
507503

508504
/**
509-
* The negotiated application protocol's "no error" code, populated
510-
* by the C++ layer when the application is selected during ALPN
511-
* negotiation. For raw QUIC this is `0n`; for HTTP/3 this is
505+
* The installed application's "no error" code, populated
506+
* by the C++ layer when the application is installed.
507+
* For raw QUIC this is `0n`; for HTTP/3 this is
512508
* `0x100n` (`H3_NO_ERROR`).
513509
* @type {bigint}
514510
*/
@@ -520,7 +516,7 @@ class QuicSessionState {
520516
}
521517

522518
/**
523-
* The negotiated application protocol's "internal error" code,
519+
* The installed application's "internal error" code,
524520
* populated by the C++ layer when the application is selected
525521
* during ALPN negotiation. Used as the wire code for `RESET_STREAM`
526522
* frames when a stream is aborted without a more specific code.
@@ -589,9 +585,9 @@ class QuicSessionState {
589585
isHandshakeConfirmed,
590586
isStreamOpenAllowed,
591587
isPrioritySupported,
592-
headersSupported,
588+
hasApplication,
593589
isWrapped,
594-
applicationType,
590+
isServer,
595591
noErrorCode,
596592
internalErrorCode,
597593
maxDatagramSize,
@@ -614,9 +610,9 @@ class QuicSessionState {
614610
isHandshakeConfirmed,
615611
isStreamOpenAllowed,
616612
isPrioritySupported,
617-
headersSupported,
613+
hasApplication,
618614
isWrapped,
619-
applicationType,
615+
isServer,
620616
noErrorCode: `${noErrorCode}`,
621617
internalErrorCode: `${internalErrorCode}`,
622618
maxDatagramSize: `${maxDatagramSize}`,
@@ -655,9 +651,9 @@ class QuicSessionState {
655651
isHandshakeConfirmed,
656652
isStreamOpenAllowed,
657653
isPrioritySupported,
658-
headersSupported,
654+
hasApplication,
659655
isWrapped,
660-
applicationType,
656+
isServer,
661657
noErrorCode,
662658
internalErrorCode,
663659
maxDatagramSize,
@@ -680,9 +676,9 @@ class QuicSessionState {
680676
isHandshakeConfirmed,
681677
isStreamOpenAllowed,
682678
isPrioritySupported,
683-
headersSupported,
679+
hasApplication,
684680
isWrapped,
685-
applicationType,
681+
isServer,
686682
noErrorCode,
687683
internalErrorCode,
688684
maxDatagramSize,

lib/internal/quic/symbols.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,22 @@ const kDatagram = Symbol('kDatagram');
3535
const kDatagramStatus = Symbol('kDatagramStatus');
3636
const kEarlyDataRejected = Symbol('kEarlyDataRejected');
3737
const kFinishClose = Symbol('kFinishClose');
38-
const kGoaway = Symbol('kGoaway');
3938
const kHandshake = Symbol('kHandshake');
4039
const kHandshakeCompleted = Symbol('kHandshakeCompleted');
4140
const kVerifyPeer = Symbol('kVerifyPeer');
42-
const kHeaders = Symbol('kHeaders');
4341
const kKeylog = Symbol('kKeylog');
4442
const kListen = Symbol('kListen');
4543
const kQlog = Symbol('kQlog');
4644
const kNewSession = Symbol('kNewSession');
4745
const kNewStream = Symbol('kNewStream');
4846
const kNewToken = Symbol('kNewToken');
49-
const kStreamCallbacks = Symbol('kStreamCallbacks');
50-
const kOrigin = Symbol('kOrigin');
5147
const kOwner = Symbol('kOwner');
5248
const kPathValidation = Symbol('kPathValidation');
5349
const kPrivateConstructor = Symbol('kPrivateConstructor');
5450
const kRemoveSession = Symbol('kRemoveSession');
5551
const kRemoveStream = Symbol('kRemoveStream');
5652
const kReset = Symbol('kReset');
57-
const kSendHeaders = Symbol('kSendHeaders');
58-
const kSessionApplication = Symbol('kSessionApplication');
5953
const kSessionTicket = Symbol('kSessionTicket');
60-
const kTrailers = Symbol('kTrailers');
6154
const kVersionNegotiation = Symbol('kVersionNegotiation');
6255

6356
module.exports = {
@@ -69,31 +62,24 @@ module.exports = {
6962
kDrain,
7063
kEarlyDataRejected,
7164
kFinishClose,
72-
kGoaway,
7365
kHandshake,
7466
kHandshakeCompleted,
7567
kVerifyPeer,
76-
kHeaders,
7768
kInspect,
7869
kKeylog,
7970
kKeyObjectHandle,
8071
kListen,
8172
kNewSession,
8273
kNewStream,
8374
kNewToken,
84-
kStreamCallbacks,
85-
kOrigin,
8675
kOwner,
8776
kQlog,
8877
kPathValidation,
8978
kPrivateConstructor,
9079
kRemoveSession,
9180
kRemoveStream,
9281
kReset,
93-
kSendHeaders,
94-
kSessionApplication,
9582
kSessionTicket,
96-
kTrailers,
9783
kVersionNegotiation,
9884
};
9985

0 commit comments

Comments
 (0)