Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag authored Nov 21, 2024
1 parent 3772d50 commit 6a78c2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/handler/redirect-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ class RedirectHandler {
// In case of HTTP 301 or 302 with POST, change the method to GET
if ((statusCode === 301 || statusCode === 302) && this.opts.method === 'POST') {
this.opts.method = 'GET'
util.destroy(this.opts.body)
util.destroy(this.opts.body.on?.('error', () => {})
this.opts.body = null
}

// https://tools.ietf.org/html/rfc7231#section-6.4.4
// In case of HTTP 303, always replace method to be either HEAD or GET
if (statusCode === 303 && this.opts.method !== 'HEAD') {
this.opts.method = 'GET'
util.destroy(this.opts.body)
util.destroy(this.opts.body.on?.('error', () => {}))
this.opts.body = null
}
}
Expand Down

0 comments on commit 6a78c2a

Please sign in to comment.