Skip to content
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

feat: implement throwOnMaxRedirect option for RedirectHandler #2563

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: Add handling for throwOnMaxRedirect flag in RedirectHandler
  • Loading branch information
Mert Can Altin committed Jan 7, 2024

Verified

This commit was created on github.com and signed with GitHub’s verified signature.
commit 6f269674d1557324d86ab70e50d4f836df708b37
2 changes: 1 addition & 1 deletion lib/handler/RedirectHandler.js
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ class RedirectHandler {
? null
: parseLocation(statusCode, headers)

if (this.history.length >= this.maxRedirections && !this.redirectionLimitReached) {
if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) {
if (this.request) {
this.request.abort()
}
2 changes: 1 addition & 1 deletion test/redirect-request.js
Original file line number Diff line number Diff line change
@@ -273,7 +273,7 @@ for (const factory of [
try {
const { statusCode, headers, body: bodyStream, context: { history } } = await request(t, server, undefined, `http://${server}/300`, {
maxRedirections: 2,
redirectionLimitReached: 2
throwOnMaxRedirect: true
})

const body = await bodyStream.text()