Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/docs/api/RedirectHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

A class that handles redirection logic for HTTP requests.

## `new RedirectHandler(dispatch, maxRedirections, opts, handler, redirectionLimitReached)`
## `new RedirectHandler(dispatch, maxRedirections, opts, handler)`

Arguments:

- **dispatch** `function` - The dispatch function to be called after every retry.
- **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`

Expand All @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/interceptors/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/redirect-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(redirectHandler)

expectType<() => void>(install)
Expand Down
6 changes: 0 additions & 6 deletions types/dispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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<string, string | string[]> }) => void;
/** Default: `null` */
Expand All @@ -170,8 +166,6 @@ declare namespace Dispatcher {
protocol?: string;
/** Default: `null` */
signal?: AbortSignal | EventEmitter | null;
/** Default: false */
redirectionLimitReached?: boolean;
/** Default: `null` */
responseHeaders?: 'raw' | null;
}
Expand Down
3 changes: 1 addition & 2 deletions types/handlers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
Loading