MCPcopy
hub / github.com/nodejs/undici / constructor

Method constructor

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

normalizeStripHeadersFunction · 0.85

Tested by

no test coverage detected