(opts, callback)
| 9 | |
| 10 | class 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) { |
nothing calls this directly
no test coverage detected