diff --git a/docs/docs/api/RedirectHandler.md b/docs/docs/api/RedirectHandler.md index bb16284fff4..ca24c6917b8 100644 --- a/docs/docs/api/RedirectHandler.md +++ b/docs/docs/api/RedirectHandler.md @@ -2,7 +2,7 @@ A class that handles redirection logic for HTTP requests. -## `new RedirectHandler(dispatch, maxRedirections, opts, handler, redirectionLimitReached)` +## `new RedirectHandler(dispatch, maxRedirections, opts, handler)` Arguments: @@ -10,7 +10,6 @@ Arguments: - **maxRedirections** `number` - Maximum number of redirections allowed. - **opts** `object` - Options for handling redirection. - **handler** `object` - An object containing handlers for different stages of the request lifecycle. -- **redirectionLimitReached** `boolean` (default: `false`) - A flag that the implementer can provide to enable or disable the feature. If set to `false`, it indicates that the caller doesn't want to use the feature and prefers the old behavior. Returns: `RedirectHandler` @@ -20,7 +19,6 @@ Returns: `RedirectHandler` - **maxRedirections** `number` (required) - Maximum number of redirections allowed. - **opts** `object` (required) - Options for handling redirection. - **handler** `object` (required) - Handlers for different stages of the request lifecycle. -- **redirectionLimitReached** `boolean` (default: `false`) - A flag that the implementer can provide to enable or disable the feature. If set to `false`, it indicates that the caller doesn't want to use the feature and prefers the old behavior. ### Properties @@ -30,7 +28,6 @@ Returns: `RedirectHandler` - **maxRedirections** `number` - Maximum number of redirections allowed. - **handler** `object` - Handlers for different stages of the request lifecycle. - **history** `Array` - An array representing the history of URLs during redirection. -- **redirectionLimitReached** `boolean` - Indicates whether the redirection limit has been reached. ### Methods diff --git a/test/interceptors/redirect.js b/test/interceptors/redirect.js index 99acfbfa80d..5e1d4252bdd 100644 --- a/test/interceptors/redirect.js +++ b/test/interceptors/redirect.js @@ -445,7 +445,7 @@ for (const factory of [ await t.completed }) - test('should follow a redirect chain up to the allowed number of times for redirectionLimitReached', async t => { + test('should throw when max redirections is reached and throwOnMaxRedirect is enabled', async t => { t = tspl(t, { plan: 1 }) const server = await startRedirectingServer() diff --git a/test/redirect-request.js b/test/redirect-request.js index 38d73e68b90..ec8317fde2c 100644 --- a/test/redirect-request.js +++ b/test/redirect-request.js @@ -406,7 +406,7 @@ for (const factory of [ await t.completed }) - test('should follow a redirect chain up to the allowed number of times for redirectionLimitReached', async t => { + test('should throw when max redirections is reached and throwOnMaxRedirect is enabled', async t => { t = tspl(t, { plan: 1 }) const server = await startRedirectingServer() diff --git a/test/types/index.test-d.ts b/test/types/index.test-d.ts index 09a6bfcd56b..2d5c425b35e 100644 --- a/test/types/index.test-d.ts +++ b/test/types/index.test-d.ts @@ -42,7 +42,7 @@ const handler: Dispatcher.DispatchHandler = {} const redirectHandler = new Undici.RedirectHandler(dispatcher.dispatch, 10, { path: '/', method: 'GET' -}, handler, false) as RedirectHandler +}, handler) as RedirectHandler expectAssignable(redirectHandler) expectType<() => void>(install) diff --git a/types/dispatcher.d.ts b/types/dispatcher.d.ts index 9f0d5d55268..33dc6051626 100644 --- a/types/dispatcher.d.ts +++ b/types/dispatcher.d.ts @@ -137,8 +137,6 @@ declare namespace Dispatcher { signal?: AbortSignal | EventEmitter | null; /** This argument parameter is passed through to `ConnectData` */ opaque?: TOpaque; - /** Default: false */ - redirectionLimitReached?: boolean; /** Default: `null` */ responseHeaders?: 'raw' | null; } @@ -147,8 +145,6 @@ declare namespace Dispatcher { opaque?: TOpaque; /** Default: `null` */ signal?: AbortSignal | EventEmitter | null; - /** Default: false */ - redirectionLimitReached?: boolean; /** Default: `null` */ onInfo?: (info: { statusCode: number, headers: Record }) => void; /** Default: `null` */ @@ -170,8 +166,6 @@ declare namespace Dispatcher { protocol?: string; /** Default: `null` */ signal?: AbortSignal | EventEmitter | null; - /** Default: false */ - redirectionLimitReached?: boolean; /** Default: `null` */ responseHeaders?: 'raw' | null; } diff --git a/types/handlers.d.ts b/types/handlers.d.ts index 8007dbf8e39..041d8d8a427 100644 --- a/types/handlers.d.ts +++ b/types/handlers.d.ts @@ -5,8 +5,7 @@ export declare class RedirectHandler implements Dispatcher.DispatchHandler { dispatch: Dispatcher.Dispatch, maxRedirections: number, opts: Dispatcher.DispatchOptions, - handler: Dispatcher.DispatchHandler, - redirectionLimitReached: boolean + handler: Dispatcher.DispatchHandler ) }