@nxtedition/lib 23.2.1 → 23.3.0
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.
- package/http.js +42 -0
- package/package.json +1 -1
package/http.js
CHANGED
|
@@ -380,6 +380,7 @@ export async function request(ctx, next) {
|
|
|
380
380
|
|
|
381
381
|
export class ServerResponse extends http.ServerResponse {
|
|
382
382
|
#created = 0
|
|
383
|
+
#bytesWritten = -1
|
|
383
384
|
#timing = {
|
|
384
385
|
connect: -1,
|
|
385
386
|
headers: -1,
|
|
@@ -391,6 +392,10 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
391
392
|
return this.#timing
|
|
392
393
|
}
|
|
393
394
|
|
|
395
|
+
get bytesWritten() {
|
|
396
|
+
return this.#bytesWritten
|
|
397
|
+
}
|
|
398
|
+
|
|
394
399
|
constructor(req) {
|
|
395
400
|
super(req)
|
|
396
401
|
|
|
@@ -426,6 +431,14 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
426
431
|
}
|
|
427
432
|
}
|
|
428
433
|
|
|
434
|
+
if (chunk != null) {
|
|
435
|
+
if (chunk.byteLength != null && this.#bytesWritten >= 0) {
|
|
436
|
+
this.#bytesWritten += chunk.byteLength
|
|
437
|
+
} else {
|
|
438
|
+
this.#bytesWritten = -1
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
429
442
|
return super.write(chunk, encoding, callback)
|
|
430
443
|
}
|
|
431
444
|
|
|
@@ -442,6 +455,14 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
442
455
|
}
|
|
443
456
|
}
|
|
444
457
|
|
|
458
|
+
if (chunk != null) {
|
|
459
|
+
if (chunk.byteLength != null && this.#bytesWritten >= 0) {
|
|
460
|
+
this.#bytesWritten += chunk.byteLength
|
|
461
|
+
} else {
|
|
462
|
+
this.#bytesWritten = -1
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
445
466
|
return super.end(chunk, encoding, callback)
|
|
446
467
|
}
|
|
447
468
|
|
|
@@ -458,6 +479,7 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
458
479
|
|
|
459
480
|
export class Http2ServerResponse extends http2.Http2ServerResponse {
|
|
460
481
|
#created = 0
|
|
482
|
+
#bytesWritten = -1
|
|
461
483
|
#timing = {
|
|
462
484
|
connect: -1,
|
|
463
485
|
headers: -1,
|
|
@@ -469,6 +491,10 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
|
|
|
469
491
|
return this.#timing
|
|
470
492
|
}
|
|
471
493
|
|
|
494
|
+
get bytesWritten() {
|
|
495
|
+
return this.#bytesWritten
|
|
496
|
+
}
|
|
497
|
+
|
|
472
498
|
constructor(req) {
|
|
473
499
|
super(req)
|
|
474
500
|
|
|
@@ -496,6 +522,14 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
|
|
|
496
522
|
}
|
|
497
523
|
}
|
|
498
524
|
|
|
525
|
+
if (chunk != null) {
|
|
526
|
+
if (chunk.byteLength != null && this.#bytesWritten >= 0) {
|
|
527
|
+
this.#bytesWritten += chunk.byteLength
|
|
528
|
+
} else {
|
|
529
|
+
this.#bytesWritten = -1
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
499
533
|
return super.write(chunk, encoding, callback)
|
|
500
534
|
}
|
|
501
535
|
|
|
@@ -512,6 +546,14 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
|
|
|
512
546
|
}
|
|
513
547
|
}
|
|
514
548
|
|
|
549
|
+
if (chunk != null) {
|
|
550
|
+
if (chunk.byteLength != null && this.#bytesWritten >= 0) {
|
|
551
|
+
this.#bytesWritten += chunk.byteLength
|
|
552
|
+
} else {
|
|
553
|
+
this.#bytesWritten = -1
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
515
557
|
return super.end(chunk, encoding, callback)
|
|
516
558
|
}
|
|
517
559
|
|