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

Draft: abort for maximum redirects rather than null #2546

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/handler/RedirectHandler.js
Expand Up @@ -5,6 +5,7 @@
const assert = require('assert')
const { InvalidArgumentError } = require('../core/errors')
const EE = require('events')
const { MAX_REDIRECTS } = require('./constants')

const redirectableStatusCodes = [300, 301, 302, 303, 307, 308]

Expand Down Expand Up @@ -87,8 +88,8 @@
}

onHeaders (statusCode, headers, resume, statusText) {
this.location = this.history.length >= this.maxRedirections || util.isDisturbed(this.opts.body)
? null
this.location = this.history.length >= this.maxRedirections ? this.abort(new Error(MAX_REDIRECTS)) : util.isDisturbed(this.opts.body) ?

Check failure on line 91 in lib/handler/RedirectHandler.js

View workflow job for this annotation

GitHub Actions / lint

Expected newline between test and consequent of ternary expression

Check failure on line 91 in lib/handler/RedirectHandler.js

View workflow job for this annotation

GitHub Actions / lint

Expected newline between consequent and alternate of ternary expression

Check failure on line 91 in lib/handler/RedirectHandler.js

View workflow job for this annotation

GitHub Actions / lint

'?' should be placed at the beginning of the line
null

Check failure on line 92 in lib/handler/RedirectHandler.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 7
: parseLocation(statusCode, headers)

if (this.opts.origin) {
Expand Down
7 changes: 7 additions & 0 deletions lib/handler/constants.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, feel free to keep the message within the handler

@@ -0,0 +1,7 @@
'use strict'

const MAX_REDIRECTS = 'Max Redirects'

module.exports = {
MAX_REDIRECTS

Check failure on line 6 in lib/handler/constants.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
}

Check failure on line 7 in lib/handler/constants.js

View workflow job for this annotation

GitHub Actions / lint

Newline required at end of file but not found