-
-
Couldn't load subscription status.
- Fork 672
feat: implement throwOnMaxRedirect option for RedirectHandler #2563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a47d463
feat: implement throwOnMaxRedirect option for RedirectHandler
c53d9de
added sidebar for apidocs
b12f302
added test for redirectionLimitReached type
6f26967
feat: Add handling for throwOnMaxRedirect flag in RedirectHandler
32b7ef3
Update RedirectHandler.js
mertcanaltin 183cdfe
fix: added error info & flow with return
8651ec4
fix: type test repair & lint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Class: RedirectHandler | ||
mertcanaltin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| A class that handles redirection logic for HTTP requests. | ||
|
|
||
| ## `new RedirectHandler(dispatch, maxRedirections, opts, handler, redirectionLimitReached)` | ||
|
|
||
| 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` | ||
|
|
||
| ### Parameters | ||
|
|
||
| - **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandlers) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every redirection. | ||
| - **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 | ||
|
|
||
| - **location** `string` - The current redirection location. | ||
| - **abort** `function` - The abort function. | ||
| - **opts** `object` - The options for handling redirection. | ||
| - **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 | ||
|
|
||
| #### `onConnect(abort)` | ||
|
|
||
| Called when the connection is established. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **abort** `function` - The abort function. | ||
|
|
||
| #### `onUpgrade(statusCode, headers, socket)` | ||
|
|
||
| Called when an upgrade is requested. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **statusCode** `number` - The HTTP status code. | ||
| - **headers** `object` - The headers received in the response. | ||
| - **socket** `object` - The socket object. | ||
|
|
||
| #### `onError(error)` | ||
|
|
||
| Called when an error occurs. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **error** `Error` - The error that occurred. | ||
|
|
||
| #### `onHeaders(statusCode, headers, resume, statusText)` | ||
|
|
||
| Called when headers are received. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **statusCode** `number` - The HTTP status code. | ||
| - **headers** `object` - The headers received in the response. | ||
| - **resume** `function` - The resume function. | ||
| - **statusText** `string` - The status text. | ||
|
|
||
| #### `onData(chunk)` | ||
|
|
||
| Called when data is received. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **chunk** `Buffer` - The data chunk received. | ||
|
|
||
| #### `onComplete(trailers)` | ||
|
|
||
| Called when the request is complete. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **trailers** `object` - The trailers received. | ||
|
|
||
| #### `onBodySent(chunk)` | ||
|
|
||
| Called when the request body is sent. | ||
|
|
||
| Parameters: | ||
|
|
||
| - **chunk** `Buffer` - The chunk of the request body sent. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.