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

Method constructor

lib/api/api-upgrade.js:11–35  ·  view source on GitHub ↗
(opts, callback)

Source from the content-addressed store, hash-verified

9
10class UpgradeHandler extends AsyncResource {
11 constructor (opts, callback) {
12 if (!opts || typeof opts !== 'object') {
13 throw new InvalidArgumentError('invalid opts')
14 }
15
16 if (typeof callback !== 'function') {
17 throw new InvalidArgumentError('invalid callback')
18 }
19
20 const { signal, opaque, responseHeaders } = opts
21
22 if (signal && typeof signal.on !== 'function' && typeof signal.addEventListener !== 'function') {
23 throw new InvalidArgumentError('signal must be an EventEmitter or EventTarget')
24 }
25
26 super('UNDICI_UPGRADE')
27
28 this.responseHeaders = responseHeaders || null
29 this.opaque = opaque || null
30 this.callback = callback
31 this.abort = null
32 this.context = null
33
34 addSignal(this, signal)
35 }
36
37 onRequestStart (controller, context) {
38 if (this.reason) {

Callers

nothing calls this directly

Calls 1

addSignalFunction · 0.85

Tested by

no test coverage detected