@@ -550,17 +550,19 @@ export interface PassThroughHandlerOptions extends PassThroughHandlerConnectionO
550550 /**
551551 * A callback that will be passed the full response before it is passed through,
552552 * and which returns a value that defines how the the response content should
553- * be transformed before it's returned to the client.
553+ * be transformed before it's returned to the client. The callback is also passed
554+ * the request that was sent to the server (as a 2nd parameter) for reference.
554555 *
555556 * The callback can either return an object to define how the response should be
556- * changed, or the string 'close' to immediately close the underlying connection.
557+ * changed, or the strings 'close' or 'reset' to immediately close/reset the
558+ * underlying connection.
557559 *
558560 * All fields on the object are optional, and returning undefined is equivalent
559561 * to returning an empty object (transforming nothing).
560562 *
561563 * See {@link CallbackResponseMessageResult} for the possible fields that can be set.
562564 */
563- beforeResponse ?: ( res : PassThroughResponse ) => MaybePromise < CallbackResponseResult | void > | void ;
565+ beforeResponse ?: ( res : PassThroughResponse , req : CompletedRequest ) => MaybePromise < CallbackResponseResult | void > | void ;
564566}
565567
566568export interface RequestTransform {
@@ -754,7 +756,7 @@ export interface BeforePassthroughRequestRequest {
754756 * @internal
755757 */
756758export interface BeforePassthroughResponseRequest {
757- args : [ Replace < PassThroughResponse , { body : string } > ] ;
759+ args : [ Replace < PassThroughResponse , { body : string } > , Replace < CompletedRequest , { body : string } > ] ;
758760}
759761
760762/**
@@ -780,7 +782,7 @@ export class PassThroughHandlerDefinition extends Serializable implements Reques
780782
781783 public readonly beforeRequest ?: ( req : CompletedRequest ) =>
782784 MaybePromise < CallbackRequestResult | void > | void ;
783- public readonly beforeResponse ?: ( res : PassThroughResponse ) =>
785+ public readonly beforeResponse ?: ( res : PassThroughResponse , req : CompletedRequest ) =>
784786 MaybePromise < CallbackResponseResult | void > | void ;
785787
786788 public readonly proxyConfig ?: ProxyConfig ;
@@ -925,7 +927,8 @@ export class PassThroughHandlerDefinition extends Serializable implements Reques
925927 CallbackResponseResult | undefined
926928 > ( 'beforeResponse' , async ( req ) => {
927929 const callbackResult = await this . beforeResponse ! (
928- withDeserializedBodyReader ( req . args [ 0 ] )
930+ withDeserializedBodyReader ( req . args [ 0 ] ) ,
931+ withDeserializedBodyReader ( req . args [ 1 ] ) ,
929932 ) ;
930933
931934 if ( typeof callbackResult === 'string' ) {
0 commit comments