@nxtedition/nxt-undici 2.0.10 → 2.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,21 +42,17 @@ class Handler {
42
42
 
43
43
  this.count += 1
44
44
 
45
- if (typeof this.opts.follow === 'function') {
46
- if (!this.opts.follow(location, this.count)) {
47
- return this.handler.onHeaders(statusCode, headers, resume, statusText)
48
- }
49
- } else {
50
- const maxCount = Number.isFinite(this.opts.follow)
51
- ? this.opts.follow
52
- : Number.isFinite(this.opts.follow?.count)
53
- ? this.opts.follow?.count
54
- : 0
55
-
56
- if (this.count >= maxCount) {
57
- // TODO (perf): Consume body?
58
- throw new Error(`Max redirections reached: ${maxCount}.`)
59
- }
45
+ // TODO (feat): follow as function...
46
+
47
+ const maxCount = Number.isFinite(this.opts.follow)
48
+ ? this.opts.follow
49
+ : Number.isFinite(this.opts.follow?.count)
50
+ ? this.opts.follow?.count
51
+ : 0
52
+
53
+ if (this.count >= maxCount) {
54
+ // TODO (perf): Consume body?
55
+ throw new Error(`Max redirections reached: ${maxCount}.`)
60
56
  }
61
57
 
62
58
  if (isDisturbed(this.opts.body)) {
@@ -83,6 +79,8 @@ class Handler {
83
79
  origin,
84
80
  }
85
81
 
82
+ this.opts.logger?.debug({ location }, 'following redirect')
83
+
86
84
  // https://tools.ietf.org/html/rfc7231#section-6.4.4
87
85
  // In case of HTTP 303, always replace method to be either HEAD or GET
88
86
  if (statusCode === 303 && this.redirectOpts.method !== 'HEAD') {
@@ -132,6 +130,7 @@ class Handler {
132
130
  count: this.count,
133
131
  }),
134
132
  )
133
+ this.handler = null
135
134
  } else {
136
135
  return this.handler.onComplete(trailers)
137
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "2.0.10",
3
+ "version": "2.0.13",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",