MCPcopy Create free account
hub / github.com/nodejs/undici / constructor

Method constructor

lib/handler/redirect-handler.js:22–41  ·  view source on GitHub ↗
(dispatch, maxRedirections, opts, handler)

Source from the content-addressed store, hash-verified

20 }
21
22 constructor (dispatch, maxRedirections, opts, handler) {
23 if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) {
24 throw new InvalidArgumentError('maxRedirections must be a positive number')
25 }
26
27 if (opts.throwOnMaxRedirect != null && typeof opts.throwOnMaxRedirect !== 'boolean') {
28 throw new InvalidArgumentError('throwOnMaxRedirect must be a boolean')
29 }
30
31 this.dispatch = dispatch
32 this.location = null
33 const { maxRedirections: _, stripHeadersOnRedirect, stripHeadersOnCrossOriginRedirect, ...cleanOpts } = opts
34 this.opts = cleanOpts // opts must be a copy, exclude maxRedirections
35 this.opts.body = util.wrapRequestBody(this.opts.body)
36 this.stripHeadersOnRedirect = normalizeStripHeaders(stripHeadersOnRedirect, 'stripHeadersOnRedirect')
37 this.stripHeadersOnCrossOriginRedirect = normalizeStripHeaders(stripHeadersOnCrossOriginRedirect, 'stripHeadersOnCrossOriginRedirect')
38 this.maxRedirections = maxRedirections
39 this.handler = handler
40 this.history = []
41 }
42
43 onRequestStart (controller, context) {
44 this.handler.onRequestStart?.(controller, { ...context, history: this.history })

Callers

nothing calls this directly

Calls 1

normalizeStripHeadersFunction · 0.85

Tested by

no test coverage detected