h2lean 0.17.2 → 0.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- // ClientHttp2Stream: the stream node hands back from `session.request()`.
1
+ // Http2ClientStream: the stream node hands back from `session.request()`.
2
2
  //
3
3
  // This mirrors `ClientHttp2Stream` in node's bundled `internal/http2/core.js`.
4
- // It is a hand-written stream over `stream.Stream` -- the server's option-A
5
- // shape (lib/stream.js) -- not a Duplex: OPTIMIZATION.md item 41 measured the
4
+ // It is a hand-written stream on the shared `Http2Stream` base (lib/Http2Stream.js)
5
+ // -- the server's option-A shape -- not a Duplex: OPTIMIZATION.md item 41 measured the
6
6
  // Duplex machinery end-to-end on the server (+1.19 us/req at 0 B, x1.54) and
7
7
  // item 42 measured the same construction on the client with a full
8
8
  // hand-written replacement that passed the whole client suite (the 0 B arm
@@ -70,33 +70,28 @@
70
70
  // nghttp2_session_consume, called at delivery), so an unread body already
71
71
  // counts against the reported number -- a reading that also stands behind
72
72
  // the client's no-partial-credit accounting, the same deliberate shape the
73
- // server documents in lib/compat.js.
73
+ // server documents in lib/server/compat.js.
74
74
  //
75
75
  // The ported surface below -- pipe()/unpipe() (the Readable.prototype.pipe
76
76
  // port, not the legacy base pipe), push(), compose(), wrap(),
77
77
  // [Symbol.asyncIterator] with the fourteen helpers, setTimeout() and
78
- // priority() -- is member-by-member from lib/stream.js, where the same shapes
78
+ // priority() -- is member-by-member from lib/Http2Stream.js, where the same shapes
79
79
  // were measured against live node servers across majors
80
80
  // (test/duplex-surface.test.js, test/pipe-parity.test.js).
81
81
  'use strict';
82
82
 
83
- const {
84
- Stream, Writable, Readable, Duplex, finished, addAbortSignal,
85
- destroy: destroyStream
86
- } = require('node:stream');
83
+
84
+ const { Duplex, finished, addAbortSignal, destroy: destroyStream } = require('node:stream');
87
85
  const { StringDecoder } = require('node:string_decoder');
88
86
  const { inspect, deprecate } = require('node:util');
89
- const { NO_ERROR, CANCEL, INTERNAL_ERROR, ST_OPEN, ST_HALF_CLOSED_LOCAL } = require('./frames');
90
- const { requestView } = require('./headers');
91
- const { errorOf, streamErrorOf, validateRstCode } = require('./stream');
87
+ const { NO_ERROR, CANCEL, INTERNAL_ERROR, ST_OPEN, ST_HALF_CLOSED_LOCAL } = require('../frames');
88
+ const { requestView } = require('../headers');
92
89
 
93
90
  // node's Http2Stream sets no highWaterMark on either side, so the values an
94
91
  // application reads are the machinery defaults -- 16384 on node 20, 65536 from
95
92
  // 22 on, measured on live streams of all four majors and equal to
96
- // `new Readable()/.writable().<side>HighWaterMark` on each (lib/stream.js
93
+ // `new Readable()/.writable().<side>HighWaterMark` on each (lib/Http2Stream.js
97
94
  // carries the same constants for the server).
98
- const WRITABLE_HWM = new Writable().writableHighWaterMark;
99
- const READABLE_HWM = new Readable().readableHighWaterMark;
100
95
 
101
96
  // node's request() destroys an aborted stream with an instance of the internal
102
97
  // AbortError class (core.js:1920 `stream.destroy(new AbortError(undefined, { cause:
@@ -123,7 +118,7 @@ class AbortError extends Error {
123
118
  const EMPTY_CB = () => {};
124
119
 
125
120
  // --- the async-iteration machinery ---------------------------------------------
126
- // Ported from lib/stream.js, which reproduces node's
121
+ // Ported from lib/Http2Stream.js, which reproduces node's
127
122
  // internal/streams/readable.js:1552-1805 (streamToAsyncIterator/createAsyncIterator)
128
123
  // and internal/streams/operators, read from the binary in the same session as the
129
124
  // measurements cited at the methods. The one adaptation is in the iterator's
@@ -132,8 +127,6 @@ const EMPTY_CB = () => {};
132
127
  // teardown route -- the AbortError instance reaches _destroyBody and derives
133
128
  // RST_STREAM(CANCEL) there (client-destroy-code.test.js pins the transcript).
134
129
 
135
- const kEmpty = Symbol('kEmpty');
136
- const kEof = Symbol('kEof');
137
130
  // %AsyncIteratorPrototype% in V8: the function's .prototype is an INSTANCE of
138
131
  // the (shared) async-generator prototype, so the intrinsic with
139
132
  // [Symbol.asyncIterator]/[Symbol.asyncDispose] and no own methods sits TWO
@@ -144,54 +137,14 @@ const kEof = Symbol('kEof');
144
137
  // intrinsic is the only anchor stable across majors, and the behaviour that
145
138
  // depends on it ([Symbol.asyncIterator] resolving through the chain,
146
139
  // self-identical) is verified per major; exact proto identity is unportable.
147
- const ASYNC_ITERATOR_PROTO =
148
- Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}.prototype));
149
-
150
- function noop() {}
151
-
152
- function validateObjectArg(value, name) {
153
- if (value === null || typeof value !== 'object') {
154
- throw errorOf('ERR_INVALID_ARG_TYPE',
155
- `The "${name}" argument must be of type object. Received ${inspect(value)}`);
156
- }
157
- }
158
140
 
159
- function validateFunctionArg(value, name) {
160
- if (typeof value !== 'function') {
161
- throw errorOf('ERR_INVALID_ARG_TYPE',
162
- `The "${name}" argument must be of type function. Received ${inspect(value)}`);
163
- }
164
- }
165
141
 
166
142
  // node's pair in every operator: validateObject(options) then
167
143
  // validateAbortSignal(options.signal).
168
- function validateSignalArg(options) {
169
- if (options != null && options.signal != null && !(options.signal instanceof AbortSignal)) {
170
- throw errorOf('ERR_INVALID_ARG_TYPE',
171
- 'The "options.signal" argument must be an instance of type AbortSignal.');
172
- }
173
- }
174
144
 
175
- function validateOperatorOptions(options) {
176
- if (options != null) {
177
- validateObjectArg(options, 'options');
178
- }
179
- validateSignalArg(options);
180
- }
181
145
 
182
146
  // node's toIntegerOrInfinity (operators:298): Number coercion per the
183
147
  // iterator-helpers proposal, then the range refusal.
184
- function toIntegerOrInfinity(number) {
185
- number = Number(number);
186
- if (Number.isNaN(number)) {
187
- return 0;
188
- }
189
- if (number < 0) {
190
- throw errorOf('ERR_OUT_OF_RANGE',
191
- `The value of "number" is out of range. It must be >= 0. Received ${number}`);
192
- }
193
- return number;
194
- }
195
148
 
196
149
  // node's createAsyncIterator (readable.js:1576). The request protocol -- next
197
150
  // fast path, queue behind an inFlight request, return/throw draining through
@@ -449,296 +402,6 @@ function createStreamIterator(stream, options) {
449
402
  // produces land exactly where node puts them. The abort error is the client's
450
403
  // own AbortError class -- the one destroy() maps onto RST_STREAM(CANCEL).
451
404
 
452
- function opMap(stream, fn, options) {
453
- validateFunctionArg(fn, 'fn');
454
- validateOperatorOptions(options);
455
- let concurrency = 1;
456
- if (options?.concurrency != null) {
457
- concurrency = Math.floor(options.concurrency);
458
- }
459
- let highWaterMark = concurrency - 1;
460
- if (options?.highWaterMark != null) {
461
- highWaterMark = Math.floor(options.highWaterMark);
462
- }
463
- if (!Number.isInteger(concurrency) || concurrency < 1) {
464
- throw errorOf('ERR_OUT_OF_RANGE',
465
- `The value of "options.concurrency" is out of range. It must be >= 1. Received ${concurrency}`);
466
- }
467
- if (!Number.isInteger(highWaterMark) || highWaterMark < 0) {
468
- throw errorOf('ERR_OUT_OF_RANGE',
469
- `The value of "options.highWaterMark" is out of range. It must be >= 0. Received ${highWaterMark}`);
470
- }
471
- highWaterMark += concurrency;
472
- // node builds its always-present signal with AbortSignal.any([...]) --
473
- // any([]) is a fresh never-aborted signal, which a never-aborted
474
- // controller's signal is byte-equivalent to for everything the operator
475
- // reads off it.
476
- const signal = options?.signal ?? new AbortController().signal;
477
-
478
- return (async function* map() {
479
- const queue = [];
480
- const signalOpt = { signal };
481
- let next = null;
482
- let resume = null;
483
- let done = false;
484
- let cnt = 0;
485
-
486
- function onCatch() {
487
- done = true;
488
- afterItemProcessed();
489
- }
490
-
491
- function afterItemProcessed() {
492
- cnt -= 1;
493
- maybeResume();
494
- }
495
-
496
- function maybeResume() {
497
- if (resume && !done && cnt < concurrency && queue.length < highWaterMark) {
498
- const r = resume;
499
- resume = null;
500
- r();
501
- }
502
- }
503
-
504
- async function pump() {
505
- try {
506
- for await (let val of stream) {
507
- if (done) {
508
- return;
509
- }
510
- if (signal.aborted) {
511
- throw new AbortError();
512
- }
513
- try {
514
- val = fn(val, signalOpt);
515
- if (val === kEmpty) {
516
- continue;
517
- }
518
- val = Promise.resolve(val);
519
- } catch (err) {
520
- val = Promise.reject(err);
521
- }
522
- cnt += 1;
523
- val.then(afterItemProcessed, onCatch);
524
- queue.push(val);
525
- if (next) {
526
- const n = next;
527
- next = null;
528
- n();
529
- }
530
- if (!done && (queue.length >= highWaterMark || cnt >= concurrency)) {
531
- await new Promise((resolve) => {
532
- resume = resolve;
533
- });
534
- }
535
- }
536
- queue.push(kEof);
537
- } catch (err) {
538
- const val = Promise.reject(err);
539
- val.then(afterItemProcessed, onCatch);
540
- queue.push(val);
541
- } finally {
542
- done = true;
543
- if (next) {
544
- const n = next;
545
- next = null;
546
- n();
547
- }
548
- }
549
- }
550
-
551
- pump();
552
-
553
- try {
554
- while (true) {
555
- while (queue.length > 0) {
556
- const val = await queue[0];
557
- if (val === kEof) {
558
- return;
559
- }
560
- if (signal.aborted) {
561
- throw new AbortError();
562
- }
563
- if (val !== kEmpty) {
564
- yield val;
565
- }
566
- queue.shift();
567
- maybeResume();
568
- }
569
- await new Promise((resolve) => {
570
- next = resolve;
571
- });
572
- }
573
- } finally {
574
- done = true;
575
- if (resume) {
576
- const r = resume;
577
- resume = null;
578
- r();
579
- }
580
- }
581
- })();
582
- }
583
-
584
- function opFilter(stream, fn, options) {
585
- validateFunctionArg(fn, 'fn');
586
- async function filterFn(value, opt) {
587
- if (await fn(value, opt)) {
588
- return value;
589
- }
590
- return kEmpty;
591
- }
592
- return opMap(stream, filterFn, options);
593
- }
594
-
595
- async function opForEach(stream, fn, options) {
596
- validateFunctionArg(fn, 'fn');
597
- async function forEachFn(value, opt) {
598
- await fn(value, opt);
599
- return kEmpty;
600
- }
601
- // node drains the mapped generator with an empty for-await body. The same
602
- // descent is spelled out here -- an fn error propagates out of the mapped
603
- // generator's own body, so its cleanup runs at the throw point and no
604
- // abrupt-close return() call from this loop would add anything.
605
- const it = opMap(stream, forEachFn, options)[Symbol.asyncIterator]();
606
- let res = await it.next();
607
- while (!res.done) {
608
- res = await it.next();
609
- }
610
- }
611
-
612
- function opFlatMap(stream, fn, options) {
613
- const values = opMap(stream, fn, options);
614
- return (async function* flatMap() {
615
- for await (const val of values) {
616
- yield* val;
617
- }
618
- })();
619
- }
620
-
621
- function opDrop(stream, number, options) {
622
- validateOperatorOptions(options);
623
- const limit = toIntegerOrInfinity(number);
624
- return (async function* drop() {
625
- if (options?.signal?.aborted) {
626
- throw new AbortError();
627
- }
628
- let numberLeft = limit;
629
- for await (const val of stream) {
630
- if (options?.signal?.aborted) {
631
- throw new AbortError();
632
- }
633
- if (numberLeft-- <= 0) {
634
- yield val;
635
- }
636
- }
637
- })();
638
- }
639
-
640
- function opTake(stream, number, options) {
641
- validateOperatorOptions(options);
642
- const limit = toIntegerOrInfinity(number);
643
- return (async function* take() {
644
- if (options?.signal?.aborted) {
645
- throw new AbortError();
646
- }
647
- let numberLeft = limit;
648
- for await (const val of stream) {
649
- if (options?.signal?.aborted) {
650
- throw new AbortError();
651
- }
652
- if (numberLeft-- > 0) {
653
- yield val;
654
- }
655
- // Don't get another item from iterator in case we reached the end --
656
- // node's comment; the return() this early exit triggers on the source
657
- // iterator is what destroys a stream taken short of its EOF.
658
- if (numberLeft <= 0) {
659
- return;
660
- }
661
- }
662
- })();
663
- }
664
-
665
- async function opSome(stream, fn, options) {
666
- for await (const unused of opFilter(stream, fn, options)) {
667
- return true;
668
- }
669
- return false;
670
- }
671
-
672
- async function opEvery(stream, fn, options) {
673
- validateFunctionArg(fn, 'fn');
674
- // https://en.wikipedia.org/wiki/De_Morgan%27s_laws -- node's comment.
675
- return !(await opSome(stream, async (...args) => !(await fn(...args)), options));
676
- }
677
-
678
- async function opFind(stream, fn, options) {
679
- for await (const result of opFilter(stream, fn, options)) {
680
- return result;
681
- }
682
- return undefined;
683
- }
684
-
685
- async function opReduce(stream, hasInitial, reducer, initialValue, options) {
686
- validateFunctionArg(reducer, 'reducer');
687
- validateOperatorOptions(options);
688
- if (options?.signal?.aborted) {
689
- const err = new AbortError(options.signal.reason);
690
- stream.once('error', () => {}); // the error is already propagated
691
- // node awaits its internal eos, which RESOLVES on the errored teardown;
692
- // the callback form wrapped here is that promise, since the public
693
- // callback-less `finished` refuses instead.
694
- await new Promise((resolve) => {
695
- // the stream's destroy() returns nothing, unlike node's, so the stream
696
- // is handed to eos on its own line.
697
- stream.destroy(err);
698
- finished(stream, resolve);
699
- });
700
- throw err;
701
- }
702
- const ac = new AbortController();
703
- const signal = ac.signal;
704
- if (options?.signal) {
705
- options.signal.addEventListener('abort', () => ac.abort(), { once: true });
706
- }
707
- let gotAnyItemFromStream = false;
708
- try {
709
- for await (const value of stream) {
710
- gotAnyItemFromStream = true;
711
- if (options?.signal?.aborted) {
712
- throw new AbortError();
713
- }
714
- if (!hasInitial) {
715
- initialValue = value;
716
- hasInitial = true;
717
- } else {
718
- initialValue = await reducer(initialValue, value, { signal });
719
- }
720
- }
721
- if (!gotAnyItemFromStream && !hasInitial) {
722
- // node's ReduceAwareErrMissingArgs: same code, same custom message.
723
- throw errorOf('ERR_MISSING_ARGS', 'Reduce of an empty stream requires an initial value');
724
- }
725
- } finally {
726
- ac.abort();
727
- }
728
- return initialValue;
729
- }
730
-
731
- async function opToArray(stream, options) {
732
- validateOperatorOptions(options);
733
- const result = [];
734
- for await (const val of stream) {
735
- if (options?.signal?.aborted) {
736
- throw new AbortError(options.signal.reason);
737
- }
738
- result.push(val);
739
- }
740
- return result;
741
- }
742
405
 
743
406
  // `sentHeaders`/`sentTrailers` and the state flags node exposes through symbols
744
407
  // are kept as plain fields here; they are not part of the documented client
@@ -747,7 +410,10 @@ async function opToArray(stream, options) {
747
410
  // only, core.js emitStreamEvent) are prototype getters over the unbuilt field
748
411
  // list: the object comes into being at the first read, which is what keeps a
749
412
  // body-only client free of per-response allocations (OPTIMIZATION.md item 48).
750
- class ClientHttp2Stream extends Stream {
413
+ const { Http2Stream, errorOf, validateRstCode, ASYNC_ITERATOR_PROTO, noop,
414
+ validateObjectArg, validateSignalArg, streamErrorOf } = require('../Http2Stream');
415
+
416
+ class Http2ClientStream extends Http2Stream {
751
417
  constructor(session, id, _opts) {
752
418
  super();
753
419
  this.id = id;
@@ -772,7 +438,7 @@ class ClientHttp2Stream extends Stream {
772
438
  this._opened = false;
773
439
  // Whether this stream is already in the session's _debt list, i.e. whether the
774
440
  // next credit pass has to visit it. Declared here so every stream shares one
775
- // V8 object shape; only lib/client-session.js reads or writes it.
441
+ // V8 object shape; only lib/client/Http2ClientSession.js reads or writes it.
776
442
  this._debtMarked = false;
777
443
  // Bytes the application has written but that flow control has not yet let us
778
444
  // frame; kept by reference so a stalled upload costs no copy.
@@ -910,12 +576,6 @@ class ClientHttp2Stream extends Stream {
910
576
  this._sid = 0;
911
577
  }
912
578
 
913
- // node's client sentHeaders is the request map with the pseudo-headers request() resolved
914
- // -- ':method' GET, ':authority' from the connect authority, ':scheme' from the transport,
915
- // ':path' '/' -- folded out of what the application passed (prepareRequestHeadersObject /
916
- // ...Array, internal/http2/util.js:717/:627, read through the getter at core.js:2225).
917
- // Resolved against the session as it stood when the request was made, and built on the
918
- // first read so a request nobody inspects pays no copy.
919
579
  get sentHeaders() {
920
580
  // A stream created from PUSH_PROMISE has neither kSentHeaders nor kRawHeaders,
921
581
  // so node's getter answers undefined (core.js:2226; measured on a live node client).
@@ -930,12 +590,6 @@ class ClientHttp2Stream extends Stream {
930
590
  return this._sentView;
931
591
  }
932
592
 
933
- // node's client keeps no response object on the stream at all -- core.js
934
- // emitStreamEvent passes the objects through the events only -- so these two
935
- // are prototype getters over the raw field list: the object comes into being
936
- // at the first read (an event argument when a listener exists, or the getter),
937
- // and one build serves every later read. A body-only client pays no
938
- // per-response object (OPTIMIZATION.md item 48).
939
593
  get responseHeaders() {
940
594
  if (this._responseObject !== undefined) {
941
595
  return this._responseObject;
@@ -966,14 +620,6 @@ class ClientHttp2Stream extends Stream {
966
620
  return o;
967
621
  }
968
622
 
969
- // ---- writable side -----------------------------------------------------------
970
- // node's Writable.write, reduced to the shapes the client surface uses: the
971
- // chunk is queued, _driveW parks it in the session's `_pending` slot and the
972
- // session's pump frames it when the windows allow; the callback answers when
973
- // the octets left (the moment the machinery's _write cb answered before).
974
- // Backpressure is the queue itself: false while anything is parked or queued,
975
- // 'drain' once when it empties -- node's highWaterMark arithmetic is not
976
- // reproduced (documented above).
977
623
  write(chunk, encoding, cb) {
978
624
  if (typeof encoding === 'function') {
979
625
  cb = encoding; encoding = undefined;
@@ -1048,15 +694,6 @@ class ClientHttp2Stream extends Stream {
1048
694
  return this;
1049
695
  }
1050
696
 
1051
- // The pump contract (lib/client-session.js _pump): exactly one chunk parked in
1052
- // `_pending` with its `_writeCb`, settled by the session when the windows let it
1053
- // frame; `_finalCb` parked for the END_STREAM behind the body. The hand-written
1054
- // half keeps that shape and adds the serialization the Writable machinery used to
1055
- // do: one chunk in flight, the rest of the queue waiting, end() parking `_finalCb`
1056
- // behind them. When the pump settles a chunk it calls the wrapper, which answers
1057
- // the application's callback and drives the next queue entry -- re-entrant with
1058
- // the pump's own loop, which re-checks `_pending` after the call and so never
1059
- // frames a chunk twice.
1060
697
  _driveW() {
1061
698
  if (this._pending !== null) {
1062
699
  return;
@@ -1090,10 +727,6 @@ class ClientHttp2Stream extends Stream {
1090
727
  }
1091
728
  }
1092
729
 
1093
- // Called by the session once the writable half has been fully framed and
1094
- // END_STREAM put on the wire. 'finish' fires one tick later, in node's order:
1095
- // writableFinished true, then the event (the machinery's prefinish/finish pair
1096
- // collapsed into one tick -- a documented simplification).
1097
730
  _writableDone() {
1098
731
  this._endSent = true;
1099
732
  const cb = this._finalCb;
@@ -1118,58 +751,12 @@ class ClientHttp2Stream extends Stream {
1118
751
  }
1119
752
  }
1120
753
 
1121
- // Writable-side corking, as a counting stub -- the server's shape (lib/stream.js
1122
- // cork()): node's Writable.cork buffers write()/end() and defers the DATA to the
1123
- // wire until corked reaches 0; the wire here sends straight through. Only the count
1124
- // is observable.
1125
- cork() {
1126
- this._corked++;
1127
- }
1128
-
1129
- uncork() {
1130
- if (this._corked > 0) {
1131
- this._corked--;
1132
- }
1133
- }
1134
-
1135
- // node's Writable.setDefaultEncoding: the WRITABLE half's default -- what an
1136
- // encoding-less write(string) encodes with. The lowercase fold and the
1137
- // ERR_UNKNOWN_ENCODING refusal are node's (lib/stream.js, measured).
1138
- setDefaultEncoding(encoding) {
1139
- if (typeof encoding === 'string') {
1140
- encoding = encoding.toLowerCase();
1141
- }
1142
- if (!Buffer.isEncoding(encoding)) {
1143
- const err = new TypeError(`Unknown encoding: ${encoding}`);
1144
- err.code = 'ERR_UNKNOWN_ENCODING';
1145
- throw err;
1146
- }
1147
- this._defaultEnc = encoding;
1148
- return this;
1149
- }
1150
-
1151
- // node's readable.setEncoding: the decoder runs at delivery, so chunks buffered
1152
- // before the call decode like chunks after it (node decodes at push() time and
1153
- // re-decodes on encoding change; the observable contract -- every 'data' and
1154
- // every read() past the call yields decoded strings -- is the same shape here,
1155
- // decoded at the delivery site instead). The delivery sites are the flowing
1156
- // emit in _onData, read(), _flushBuffered, push() and the decoder.end() tail in
1157
- // _scheduleEnd; a decoder holding a partial multibyte char returns '' and
1158
- // nothing is delivered for it (measured: node pushes one 'data' for a char
1159
- // split across two chunks, never an empty string).
1160
754
  setEncoding(encoding) {
1161
755
  this._decoder = new StringDecoder(encoding);
1162
756
  this._encoding = encoding;
1163
757
  return this;
1164
758
  }
1165
759
 
1166
- // ---- readable half -----------------------------------------------------------
1167
- // Flowing mode is the synchronous emit('data') the server's _recvData uses -- the
1168
- // fast path item 42 gated, with no readableState and no nextTick flow loop. Paused
1169
- // mode buffers and serves read(); 'end' is scheduled one tick after the queue
1170
- // drains at a known EOF, the one nextTick the delivery pays (node's endReadable).
1171
- // The 'end'-waits-for-the-drain rule and the node-kick (an unconsumed response
1172
- // still reaches 'end') both carry over from _endRead.
1173
760
  _onData(buf) {
1174
761
  this._remoteEnded = false;
1175
762
  // The session can hand over an empty DATA payload (_onDataFrame delivers
@@ -1346,7 +933,6 @@ class ClientHttp2Stream extends Stream {
1346
933
  });
1347
934
  }
1348
935
 
1349
- // The session decoded END_STREAM for this stream (or a destroy forces the EOF).
1350
936
  _endRead() {
1351
937
  if (this._remoteEnded) {
1352
938
  return;
@@ -1367,12 +953,6 @@ class ClientHttp2Stream extends Stream {
1367
953
  this._scheduleEnd();
1368
954
  }
1369
955
 
1370
- // node's Readable.push, at this stream's delivery fidelity: flowing delivers
1371
- // synchronously through the decoder, paused queues and wakes 'readable'. The
1372
- // decision order is node's readableAddChunkPushByteMode: convert, then the
1373
- // empty-chunk branch, and only after it the after-EOF error and the destroyed
1374
- // silence (lib/stream.js push(), measured against node). An empty chunk queues
1375
- // nothing and there is no watermark, so the canPushMore verdict is always true.
1376
956
  push(chunk, encoding) {
1377
957
  if (chunk === null) {
1378
958
  // push(null) is the EOF into the readable queue: silent when the EOF is
@@ -1464,8 +1044,6 @@ class ClientHttp2Stream extends Stream {
1464
1044
  return this;
1465
1045
  }
1466
1046
 
1467
- // node's isPaused reads flowing === false (measured: false on a fresh stream,
1468
- // true after pause(), false again after resume()).
1469
1047
  isPaused() {
1470
1048
  return this._flowing === false;
1471
1049
  }
@@ -1491,9 +1069,6 @@ class ClientHttp2Stream extends Stream {
1491
1069
  }
1492
1070
  }
1493
1071
 
1494
- // node: attaching 'data' flips the stream flowing and flushes whatever buffered
1495
- // on the resume tick (readable.js data-listener resume). once('data') misses
1496
- // this -- the same gap the server's on() override carries.
1497
1072
  on(name, fn) {
1498
1073
  if (name === 'data' && this._flowing !== true && !this._destroyFlag) {
1499
1074
  this._flowing = true;
@@ -1509,11 +1084,6 @@ class ClientHttp2Stream extends Stream {
1509
1084
  return super.on(name, fn);
1510
1085
  }
1511
1086
 
1512
- // node's autoDestroy: the stream closes itself when both halves are done. The
1513
- // gate reads the two flags the machinery would have -- the readable side's
1514
- // scheduled 'end' and the writable side's END_STREAM on the wire. A GET whose
1515
- // request writable the application never ended never auto-closes (node's
1516
- // machinery does not close it either; the session dropped the id already).
1517
1087
  _maybeAutoClose() {
1518
1088
  if (this._destroyFlag || this._endEmitted !== true || this._endSent !== true) {
1519
1089
  return;
@@ -1521,17 +1091,6 @@ class ClientHttp2Stream extends Stream {
1521
1091
  this.destroy();
1522
1092
  }
1523
1093
 
1524
- // node's closeStream (core.js:2071) minus the RST submission, which each caller
1525
- // decides for itself: _destroy forces one, the session's outbound refusal submits the
1526
- // refusal's own code, and an inbound reset submits none (kNoRstStream). What is shared
1527
- // is the record and the writable half -- 'aborted' turns on whether end() was *called*,
1528
- // not whether the octets went out, so a request body still open is 'aborted' and then
1529
- // ended, and the stream reports 'finish' and writableEnded like node's (measured on
1530
- // v26.12.1 for codes 0, 1 and 8 against a raw peer, with and without END_STREAM).
1531
- // The ending flip is done directly instead of through public end(): _destroy's
1532
- // closeStream runs after destroy() already flagged the stream, and node's
1533
- // closeStream ends the writable during teardown without the application-facing
1534
- // destroyed guard.
1535
1094
  _closeStream(code, errored) {
1536
1095
  this._closed = true;
1537
1096
  this.rstCode = code;
@@ -1559,12 +1118,6 @@ class ClientHttp2Stream extends Stream {
1559
1118
  }
1560
1119
  }
1561
1120
 
1562
- // The peer reset this stream. node runs two steps in this order -- closeStream, then
1563
- // the readable decision in onStreamClose (internal/http2/core.js:607) -- and both are
1564
- // observable: the writable half is closed first, and a clean reset waits for the
1565
- // buffered body instead of discarding it. onStreamClose then calls `stream.destroy()`
1566
- // with NO error (core.js:624): the error the application sees is the one _destroy
1567
- // synthesizes from rstCode, which is why the code has to be recorded before it.
1568
1121
  _onRst(code) {
1569
1122
  this._reset = true;
1570
1123
  this._closeStream(code);
@@ -1580,19 +1133,6 @@ class ClientHttp2Stream extends Stream {
1580
1133
  this.destroy();
1581
1134
  }
1582
1135
 
1583
- // Destroying the stream is how the application abandons a request
1584
- // (`stream.destroy()`, or `close()`). node derives the code here
1585
- // (core.js:2503-2522) rather than fixing it: a stream whose wire life already
1586
- // ended keeps the code it closed with, otherwise the session's goaway/destroy
1587
- // code is the starting point, and an error overrides it -- the session's code
1588
- // first, then CANCEL for node's own AbortError, then INTERNAL_ERROR. Measured on
1589
- // a live node client against a raw peer: destroy() frames RST_STREAM(0) and
1590
- // reports rstCode 0, destroy(new Error()) frames RST_STREAM(2) and reports
1591
- // rstCode 2, and an aborted options.signal frames RST_STREAM(8) and reports
1592
- // rstCode 8. The old unconditional rstStream(id) framed CANCEL for all three
1593
- // and left rstCode at 0. The teardown runs one tick after the call (node's
1594
- // destroy chain defers _destroy the same way); 'error' then 'close' fire from
1595
- // that tick, one tick earlier than the machinery's emitErrorNT pair.
1596
1136
  destroy(err) {
1597
1137
  if (this._destroyFlag) {
1598
1138
  // streams.destroy() silently drops an error handed to an already-destroyed
@@ -1704,19 +1244,6 @@ class ClientHttp2Stream extends Stream {
1704
1244
  }
1705
1245
  }
1706
1246
 
1707
- // node: Http2Stream.close (internal/http2/core.js:2474) -- validateInteger 0..2^32-1,
1708
- // validateFunction; a second call on a closed stream is a silent no-op; the callback
1709
- // rides 'close' and receives no arguments (measured: cb(0)). closeStream's RST default
1710
- // is kSubmitRstStream (core.js:2071): it goes out at once unless the writable was
1711
- // already ending, not finished, and the code is NO_ERROR -- that shape rides 'finish'
1712
- // (core.js:2095-2101; the `ending` there is destructured BEFORE closeStream's own
1713
- // end() flips it, which is why a POST with an open body RSTs at once). Measured on a
1714
- // live node v26.12.1 client: a GET (auto-ended and finished) and that open-body POST
1715
- // -- which 'aborted's, its writable never having ended -- both RST at once, and the
1716
- // JS teardown ('error' for a code past 0 and 8, then 'close') lands a turn later,
1717
- // with the full state object still readable in the same tick. destroy() itself runs
1718
- // its body inline here; close() defers the destroy one tick to keep that same-tick
1719
- // state read.
1720
1247
  close(code = NO_ERROR, callback) {
1721
1248
  validateRstCode(code, callback);
1722
1249
  if (this.closed) {
@@ -1738,10 +1265,6 @@ class ClientHttp2Stream extends Stream {
1738
1265
  this._tick(() => this.destroy());
1739
1266
  }
1740
1267
 
1741
- // node's Http2Stream.sendTrailers(headers) -- the same base method the server stream
1742
- // exposes, so the same three guards in the same order, all synchronous throws:
1743
- // destroyed -> ERR_HTTP2_INVALID_STREAM, already sent -> ERR_HTTP2_TRAILERS_ALREADY_SENT,
1744
- // and 'wantTrailers' not yet emitted -> ERR_HTTP2_TRAILERS_NOT_READY.
1745
1268
  sendTrailers(trailers) {
1746
1269
  if (this._destroyFlag) {
1747
1270
  const err = new Error('The stream has been destroyed');
@@ -1773,14 +1296,6 @@ class ClientHttp2Stream extends Stream {
1773
1296
  this.sentTrailers = Object.assign({ __proto__: null }, trailers);
1774
1297
  }
1775
1298
 
1776
- // node's Readable.prototype.pipe (internal/streams/readable.js:978), not the
1777
- // legacy Stream.prototype.pipe the bare base would supply: the tracked
1778
- // destination list, the unpipe() surface, and the teardown that makes a
1779
- // destroyed or finished source end and unpipe its destinations -- measured
1780
- // on a live node the sink of a stream destroyed mid-pipe reports
1781
- // pipe,finish,unpipe,close where the legacy base stops at pipe,close
1782
- // (test/pipe-parity.test.js). The await-drain bookkeeping is node's
1783
- // single-dest fast value promoted to a Set for the second destination.
1784
1299
  pipe(dest, options) {
1785
1300
  const src = this;
1786
1301
  if (src._pipes === null) {
@@ -1916,47 +1431,6 @@ class ClientHttp2Stream extends Stream {
1916
1431
  return dest;
1917
1432
  }
1918
1433
 
1919
- // node's Readable.prototype.unpipe (readable.js:1180): no argument removes
1920
- // every destination and stops the flow; one argument removes that
1921
- // destination if it is piped to, and the call is its own 'unpipe' event
1922
- // onto the dest with the hasUnpiped record the pipe closure cleans up on.
1923
- unpipe(dest) {
1924
- const pipes = this._pipes;
1925
- if (pipes === null || pipes.length === 0) {
1926
- return this;
1927
- }
1928
- if (!dest) {
1929
- const dests = pipes;
1930
- this._pipes = [];
1931
- this.pause();
1932
- for (let i = 0; i < dests.length; i++) {
1933
- dests[i].emit('unpipe', this, { hasUnpiped: false });
1934
- }
1935
- return this;
1936
- }
1937
- const index = pipes.indexOf(dest);
1938
- if (index === -1) {
1939
- return this;
1940
- }
1941
- pipes.splice(index, 1);
1942
- if (pipes.length === 0) {
1943
- this.pause();
1944
- }
1945
- dest.emit('unpipe', this, { hasUnpiped: false });
1946
- return this;
1947
- }
1948
-
1949
- // node's Readable.prototype.compose (readable.js:1810 plus
1950
- // internal/streams/compose.js, the Node-stream branch): the composed Duplex
1951
- // writes into this and reads out of the chain behind it. h2lean drives the
1952
- // two-stream chain with its own pipe() above -- the port of
1953
- // Readable.prototype.pipe -- where node uses internal/streams/pipeline; for
1954
- // the prototype method's single argument those are the same chain (src
1955
- // 'end' -> dest.end(), src error -> dest teardown), and the rest is node's
1956
- // wiring verbatim: d._write into head with the drain callback, d._final =
1957
- // head.end(), tail 'data'/'end' into d.push, teardown destroying the tail.
1958
- // Web streams (TransformStream and friends) are refused here where node
1959
- // composes them -- KNOWN DIVERGENCE, stated in the header.
1960
1434
  compose(stream, options) {
1961
1435
  if (options != null) {
1962
1436
  validateObjectArg(options, 'options');
@@ -2063,134 +1537,6 @@ class ClientHttp2Stream extends Stream {
2063
1537
  return d;
2064
1538
  }
2065
1539
 
2066
- // node's legacy Readable.prototype.wrap (readable.js:1503) -- the "ugly
2067
- // unfortunate mess of history" that turns any event source into readable
2068
- // data on this stream. It is honest machinery here because push() is node's
2069
- // and the pull-side resume hook fires where node's maybeReadMore would call
2070
- // _read.
2071
- wrap(stream) {
2072
- let paused = false;
2073
- stream.on('data', (chunk) => {
2074
- if (!this.push(chunk) && stream.pause) {
2075
- paused = true;
2076
- stream.pause();
2077
- }
2078
- });
2079
- stream.on('end', () => {
2080
- this.push(null);
2081
- });
2082
- stream.on('error', (err) => {
2083
- if (!this.destroyed) {
2084
- this.destroy(err);
2085
- }
2086
- });
2087
- stream.on('close', () => {
2088
- if (!this.destroyed) {
2089
- this.destroy();
2090
- }
2091
- });
2092
- stream.on('destroy', () => {
2093
- if (!this.destroyed) {
2094
- this.destroy();
2095
- }
2096
- });
2097
- this._read = () => {
2098
- if (paused && stream.resume) {
2099
- paused = false;
2100
- stream.resume();
2101
- }
2102
- };
2103
- const streamKeys = Object.keys(stream);
2104
- for (let j = 0; j < streamKeys.length; j++) {
2105
- const i = streamKeys[j];
2106
- if (this[i] === undefined && typeof stream[i] === 'function') {
2107
- this[i] = stream[i].bind(stream);
2108
- }
2109
- }
2110
- return this;
2111
- }
2112
-
2113
- // --- the async-iteration surface ---------------------------------------------
2114
- // node's readable-iteration protocol and the fourteen helpers the public
2115
- // `stream` module bolts onto the same prototype (lib/stream.js carries the
2116
- // server-side port and the measurements): the transform family returns
2117
- // `Readable.from(generator)` -- measured on a live node stream: `map(fn)`
2118
- // yields an objectMode Readable -- and the promise family returns the
2119
- // operation's promise. The iterator itself is a pull machine over read();
2120
- // break over for-await destroys through the iterator's return() (the
2121
- // AbortError into destroy(), RST CANCEL(8), events aborted, error:ABORT_ERR,
2122
- // close), while a natural end leaves the stream alive -- node reaches
2123
- // finalize() in both cases, but Http2Stream sets autoDestroy false
2124
- // (core.js:2132), so only the still-active return() branch satisfies
2125
- // finalize's second clause.
2126
- [Symbol.asyncIterator]() {
2127
- return createStreamIterator(this, undefined);
2128
- }
2129
-
2130
- iterator(options) {
2131
- if (options !== undefined) {
2132
- validateObjectArg(options, 'options');
2133
- }
2134
- return createStreamIterator(this, options);
2135
- }
2136
-
2137
- map(fn, options) {
2138
- return Readable.from(opMap(this, fn, options));
2139
- }
2140
-
2141
- filter(fn, options) {
2142
- return Readable.from(opFilter(this, fn, options));
2143
- }
2144
-
2145
- flatMap(fn, options) {
2146
- return Readable.from(opFlatMap(this, fn, options));
2147
- }
2148
-
2149
- drop(number, options) {
2150
- return Readable.from(opDrop(this, number, options));
2151
- }
2152
-
2153
- take(number, options) {
2154
- return Readable.from(opTake(this, number, options));
2155
- }
2156
-
2157
- reduce(reducer, initialValue, options) {
2158
- // node's reduce tests `arguments.length > 1` inside the operator to tell
2159
- // "no initial value" from "initial value undefined"; the arity has to be
2160
- // read at the call, which is here.
2161
- return opReduce(this, arguments.length > 1, reducer, initialValue, options);
2162
- }
2163
-
2164
- forEach(fn, options) {
2165
- return opForEach(this, fn, options);
2166
- }
2167
-
2168
- toArray(options) {
2169
- return opToArray(this, options);
2170
- }
2171
-
2172
- some(fn, options) {
2173
- return opSome(this, fn, options);
2174
- }
2175
-
2176
- every(fn, options) {
2177
- return opEvery(this, fn, options);
2178
- }
2179
-
2180
- find(fn, options) {
2181
- return opFind(this, fn, options);
2182
- }
2183
-
2184
- // node maps a per-stream timeout onto the connection's idle timeout.
2185
- setTimeout(ms, cb) {
2186
- this.session.setTimeout(ms, cb);
2187
- return this;
2188
- }
2189
-
2190
- // RFC 9218 deprecates the priority scheme; node still accepts the call but
2191
- // refuses a destroyed stream (internal/http2/core.js:2617). Returning true
2192
- // without reordering anything is the honest v1 answer. The DEP0194 warning
2193
- // is attached below the class, byte-identical to node's (typo included).
2194
1540
  priority() {
2195
1541
  if (this._destroyFlag) {
2196
1542
  throw errorOf('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed');
@@ -2198,66 +1544,22 @@ class ClientHttp2Stream extends Stream {
2198
1544
  return true;
2199
1545
  }
2200
1546
 
2201
- // --- the state node exposes through its machinery ----------------------------
2202
- // Measured member-by-member off a live node client stream (v26.12.1: a fresh
2203
- // GET request reads readableFlowing null, isPaused false, writable false with
2204
- // writableEnded true because the request HEADERS carried END_STREAM, both
2205
- // high-water marks at the machinery defaults; after 'close': destroyed true,
2206
- // closed true, readableEnded true, readableDidRead true). Every getter is
2207
- // computed from state this file already keeps, plus the five lazily-written
2208
- // flags (_rEof, _endEmitted, _endDelivered, _dataRead, _flowing) written at
2209
- // the delivery/decision points above -- no per-request allocation beyond the
2210
- // two stub state objects the session pokes.
2211
-
2212
1547
  get destroyed() {
2213
1548
  return this._destroyFlag;
2214
1549
  }
2215
1550
 
2216
- // node's STREAM_FLAGS_CLOSED through Http2Stream.closed (core.js), set by
2217
- // closeStream: false until the wire life ended with a code.
2218
1551
  get closed() {
2219
1552
  return this._closed;
2220
1553
  }
2221
1554
 
2222
- // node: Http2Stream.pending (core.js:2264) reads `this[kID] === undefined` --
2223
- // the id does not exist until requestOnConnect submits the request. h2lean
2224
- // reserves the id in request() and queues the whole request behind the
2225
- // connecting session or a concurrency slot, so the same question is answered
2226
- // from _opened: true until _openStream() frames the HEADERS, false afterwards,
2227
- // and false stays through close the way node's assigned id stays assigned
2228
- // (a queued stream destroyed before it opens reads true on both stacks).
2229
1555
  get pending() {
2230
1556
  return !this._opened;
2231
1557
  }
2232
1558
 
2233
- // node: Http2Stream.sentInfoHeaders (core.js:2260) reads kInfoHeaders, which
2234
- // only the SERVER additionalHeaders() populates (core.js:3284); the client
2235
- // receive path for 1xx blocks writes nothing there, so a client stream reads
2236
- // undefined for its whole life -- measured on a live node v26.12.1 client
2237
- // after a received 103 and a 100. The getter exists so
2238
- // `'sentInfoHeaders' in req` sees the same surface; the received blocks
2239
- // themselves surface as the 'headers'/'continue' events and the
2240
- // additionalHeaders field.
2241
1559
  get sentInfoHeaders() {
2242
1560
  return undefined;
2243
1561
  }
2244
1562
 
2245
- // node: Http2Stream.state (core.js:2304) answers {} when destroyed or before the
2246
- // stream has an id, else the six getStreamState fields (internal util). Measured on
2247
- // a live node v26.12.1 client: weight 16, sumDependencyWeight 0, remoteClose 0 in
2248
- // every phase reachable before teardown (an inbound RST destroys first), localClose
2249
- // 1 once the request ended, and localWindowSize = the peer's initial window minus
2250
- // consumed-but-not-yet-credited octets (16 KiB consumed reads 49151; node credits
2251
- // at its own thresholds, so only the subtraction is pinned, not a post-credit
2252
- // value). The subtraction reads _recvUsed, which books octets at DATA ARRIVAL,
2253
- // not at consumption -- node consumes at delivery -- so an unread body already
2254
- // counts here; the header list carries the divergence and its reason.
2255
- // Divergences in the header list: node's one-turn IDLE shape (state 1, weight 0,
2256
- // window 0) between request() and the first flush does not exist here -- the
2257
- // HEADERS frame is built in the call; a request queued behind a connecting
2258
- // session reads {} here like node's pending shape, because _opened is still
2259
- // false (the id itself is reserved at request() time -- node's queued stream
2260
- // has no id yet, the one divergence the pending getter below cannot cover).
2261
1563
  get state() {
2262
1564
  if (this._destroyFlag || this._opened !== true) {
2263
1565
  return {};
@@ -2272,41 +1574,19 @@ class ClientHttp2Stream extends Stream {
2272
1574
  };
2273
1575
  }
2274
1576
 
2275
- // The flag that names a HEAD request is set only on the server side of node's
2276
- // stream construction (core.js:416/3046); a client stream never carries it, and a
2277
- // HEAD request through request() reads false (measured v26.12.1).
2278
1577
  get headRequest() {
2279
1578
  return false;
2280
1579
  }
2281
1580
 
2282
- // node: `!r.destroyed && !r.errorEmitted && !r.endEmitted` -- readable-side,
2283
- // not half-open-ness: a stream that has emitted 'end' reads false with both
2284
- // halves alive.
2285
1581
  get readable() {
2286
1582
  return this._destroyFlag !== true && this._readableState.errorEmitted !== true &&
2287
1583
  this._endDelivered !== true;
2288
1584
  }
2289
1585
 
2290
- // node's readableDidRead is the dataEmitted bit (readable.js:1857): true once any
2291
- // delivery of octets happened -- through a 'data' event OR a successful read(),
2292
- // because node's read() itself emits 'data' on every chunk it hands back.
2293
- get readableDidRead() {
2294
- return this._dataRead === true;
2295
- }
2296
-
2297
- // The 'end' event has been emitted -- node's endEmitted bit flips at the
2298
- // emission, not at the scheduling, hence the delivered flag.
2299
1586
  get readableEnded() {
2300
1587
  return this._endDelivered === true;
2301
1588
  }
2302
1589
 
2303
- // node's tri-state (readable.js:1901): null until anything ever touches the
2304
- // readable side, true while it flows, false while paused.
2305
- get readableFlowing() {
2306
- return this._flowing === undefined ? null : this._flowing;
2307
- }
2308
-
2309
- // node: `readable !== false && (destroyed || errored) && !endEmitted`.
2310
1590
  get readableAborted() {
2311
1591
  return (this._destroyFlag || this._errored !== undefined) &&
2312
1592
  this._endDelivered !== true;
@@ -2316,14 +1596,6 @@ class ClientHttp2Stream extends Stream {
2316
1596
  return this._encoding;
2317
1597
  }
2318
1598
 
2319
- get readableHighWaterMark() {
2320
- return READABLE_HWM;
2321
- }
2322
-
2323
- get readableObjectMode() {
2324
- return false;
2325
- }
2326
-
2327
1599
  get readableLength() {
2328
1600
  const rbuf = this._rbuf;
2329
1601
  if (rbuf === null) {
@@ -2336,13 +1608,10 @@ class ClientHttp2Stream extends Stream {
2336
1608
  return n;
2337
1609
  }
2338
1610
 
2339
- // node returns the buffer list itself; h2lean hands out a copy -- the live
2340
- // array would let the caller splice chunks out from under the delivery queue.
2341
1611
  get readableBuffer() {
2342
1612
  return this._rbuf === null ? [] : this._rbuf.slice();
2343
1613
  }
2344
1614
 
2345
- // node: `(kEnding | kEnded | kDestroyed | kErrored) === 0`.
2346
1615
  get writable() {
2347
1616
  return this._destroyFlag !== true && this._endQueued !== true &&
2348
1617
  this._errored === undefined;
@@ -2352,12 +1621,6 @@ class ClientHttp2Stream extends Stream {
2352
1621
  return this._endQueued;
2353
1622
  }
2354
1623
 
2355
- get writableObjectMode() {
2356
- return false;
2357
- }
2358
-
2359
- // The octets still queued behind the one chunk in flight; the in-flight chunk
2360
- // lives in the session's `_pending` slot (write-through, header above).
2361
1624
  get writableLength() {
2362
1625
  const wq = this._wq;
2363
1626
  if (wq === null) {
@@ -2381,45 +1644,19 @@ class ClientHttp2Stream extends Stream {
2381
1644
  return out;
2382
1645
  }
2383
1646
 
2384
- // node: `kNeedDrain` set and neither destroyed nor ending.
2385
1647
  get writableNeedDrain() {
2386
1648
  return this._needDrain === true && this._destroyFlag !== true &&
2387
1649
  this._endQueued !== true;
2388
1650
  }
2389
1651
 
2390
- // core.js:2215: `writeQueueSize + writableLength`. The nghttp2 queue this
2391
- // file has no equivalent for (write-through, header above), so the second
2392
- // term is the whole number.
2393
- get bufferSize() {
2394
- return this.writableLength;
2395
- }
2396
-
2397
- get writableCorked() {
2398
- return this._corked;
2399
- }
2400
-
2401
- get writableHighWaterMark() {
2402
- return WRITABLE_HWM;
2403
- }
2404
-
2405
1652
  get writableFinished() {
2406
1653
  return this._writableState.finished;
2407
1654
  }
2408
1655
 
2409
- // node keeps one `errored` per half; the public getter is the READABLE one
2410
- // (readable.js:1939). It holds the Error an 'error' is delivering, set when
2411
- // destroy runs with an error (destroy.js checkError), not when the event fires.
2412
1656
  get errored() {
2413
1657
  return this._errored === undefined ? null : this._errored;
2414
1658
  }
2415
1659
 
2416
- // The session decoded a response (or informational / trailer) block for us.
2417
- // The field list arrives unbuilt: the null-prototype object with `:status`
2418
- // coerced to a number and `set-cookie` as an array is what the session's
2419
- // _toObject builds, and it is built here at the first read -- an event
2420
- // argument when a listener exists, or the responseHeaders/trailers getter.
2421
- // A body-only client (no 'response' subscription, no getter read) pays no
2422
- // per-response object at all; the paired marginal is OPTIMIZATION.md item 48.
2423
1660
  _onHeaders(status, fields, fcount, sensitive, end, flags) {
2424
1661
  if (status !== undefined && status >= 100 && status < 200 && !this.responseEmitted) {
2425
1662
  // 1xx informational (including the 100 Continue that node surfaces as
@@ -2462,14 +1699,22 @@ class ClientHttp2Stream extends Stream {
2462
1699
  this._endRead();
2463
1700
  }
2464
1701
  }
1702
+
1703
+ _abortError() {
1704
+ return new AbortError();
1705
+ }
1706
+
1707
+ _createIterator(options) {
1708
+ return createStreamIterator(this, options);
1709
+ }
2465
1710
  }
2466
1711
 
2467
1712
  // node wraps the whole method in util.deprecate, so the warning fires once per
2468
1713
  // process with this exact message -- typo included, byte-identical to
2469
1714
  // internal/http2/core.js:2620 (DEP0194).
2470
- ClientHttp2Stream.prototype.priority = deprecate(
2471
- ClientHttp2Stream.prototype.priority,
1715
+ Http2ClientStream.prototype.priority = deprecate(
1716
+ Http2ClientStream.prototype.priority,
2472
1717
  'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 9113',
2473
1718
  'DEP0194');
2474
1719
 
2475
- module.exports = { ClientHttp2Stream, AbortError };
1720
+ module.exports = { Http2ClientStream, AbortError };