handleUpgrade(req, socket, head, cb) {
        socket.on('error', $d11422b22cc93234$var$socketOnError);
        const key = req.headers['sec-websocket-key'] !== undefined ? req.headers['sec-websocket-key'].trim() : false;
        const version = +req.headers['sec-websocket-version'];
        const extensions = {
        };
        if (req.method !== 'GET' || req.headers.upgrade.toLowerCase() !== 'websocket' || !key || !$d11422b22cc93234$var$keyRegex.test(key) || version !== 8 && version !== 13 || !this.shouldHandle(req)) return $d11422b22cc93234$var$abortHandshake(socket, 400);
        if (this.options.perMessageDeflate) {
            const perMessageDeflate = new $a3204058aeffecb3$exports(this.options.perMessageDeflate, true, this.options.maxPayload);
            try {
                const offers = $d11422b22cc93234$require$parse(req.headers['sec-websocket-extensions']);
                if (offers[$a3204058aeffecb3$exports.extensionName]) {
                    perMessageDeflate.accept(offers[$a3204058aeffecb3$exports.extensionName]);
                    extensions[$a3204058aeffecb3$exports.extensionName] = perMessageDeflate;
                }
            } catch (err) {
                return $d11422b22cc93234$var$abortHandshake(socket, 400);
            }
        }
        //
        // Optionally call external client verification handler.
        //
        if (this.options.verifyClient) {
            const info = {
                origin: req.headers[`${version === 8 ? 'sec-websocket-origin' : 'origin'}`],
                secure: !!(req.socket.authorized || req.socket.encrypted),
                req: req
            };
            if (this.options.verifyClient.length === 2) {
                this.options.verifyClient(info, (verified, code, message, headers)=>{
                    if (!verified) return $d11422b22cc93234$var$abortHandshake(socket, code || 401, message, headers);
                    this.completeUpgrade(key, extensions, req, socket, head, cb);
                });
                return;
            }
            if (!this.options.verifyClient(info)) return $d11422b22cc93234$var$abortHandshake(socket, 401);
        }
        this.completeUpgrade(key, extensions, req, socket, head, cb);
    }
/**
   * Handle a HTTP Upgrade request.
   *
   * @param {http.IncomingMessage} req The request object
   * @param {(net.Socket|tls.Socket)} socket The network socket between the
   *     server and client
   * @param {Buffer} head The first packet of the upgraded stream
   * @param {Function} cb Callback
   * @public
   */
Handle a HTTP Upgrade request.
Handle a HTTP Upgrade request .
handleUpgrade(req, socket, head, cb) {
        socket.on('error', $d11422b22cc93234$var$socketOnError);
        const key = req.headers['sec-websocket-key'] !== undefined ? req.headers['sec-websocket-key'].trim() : false;
        const version = +req.headers['sec-websocket-version'];
        const extensions = {
        };
        if (req.method !== 'GET' || req.headers.upgrade.toLowerCase() !== 'websocket' || !key || !$d11422b22cc93234$var$keyRegex.test(key) || version !== 8 && version !== 13 || !this.shouldHandle(req)) return $d11422b22cc93234$var$abortHandshake(socket, 400);
        if (this.options.perMessageDeflate) {
            const perMessageDeflate = new $a3204058aeffecb3$exports(this.options.perMessageDeflate, true, this.options.maxPayload);
            try {
                const offers = $d11422b22cc93234$require$parse(req.headers['sec-websocket-extensions']);
                if (offers[$a3204058aeffecb3$exports.extensionName]) {
                    perMessageDeflate.accept(offers[$a3204058aeffecb3$exports.extensionName]);
                    extensions[$a3204058aeffecb3$exports.extensionName] = perMessageDeflate;
                }
            } catch (err) {
                return $d11422b22cc93234$var$abortHandshake(socket, 400);
            }
        }
         Optionally call external client verification handler.
        if (this.options.verifyClient) {
            const info = {
                origin: req.headers[`${version === 8 ? 'sec-websocket-origin' : 'origin'}`],
                secure: !!(req.socket.authorized || req.socket.encrypted),
                req: req
            };
            if (this.options.verifyClient.length === 2) {
                this.options.verifyClient(info, (verified, code, message, headers)=>{
                    if (!verified) return $d11422b22cc93234$var$abortHandshake(socket, code || 401, message, headers);
                    this.completeUpgrade(key, extensions, req, socket, head, cb);
                });
                return;
            }
            if (!this.options.verifyClient(info)) return $d11422b22cc93234$var$abortHandshake(socket, 401);
        }
        this.completeUpgrade(key, extensions, req, socket, head, cb);
    }
handleUpgrade ( req , socket , head , cb ) { socket . on ( 'error' , $d11422b22cc93234$var$socketOnError ) ; const key = req . headers [ 'sec-websocket-key' ] !== undefined ? req . headers [ 'sec-websocket-key' ] . trim ( ) : false ; const version = + req . headers [ 'sec-websocket-version' ] ; const extensions = { } ; if ( req . method !== 'GET' || req . headers . upgrade . toLowerCase ( ) !== 'websocket' || ! key || ! $d11422b22cc93234$var$keyRegex . test ( key ) || version !== 8 && version !== 13 || ! this . shouldHandle ( req ) ) return $d11422b22cc93234$var$abortHandshake ( socket , 400 ) ; if ( this . options . perMessageDeflate ) { const perMessageDeflate = new $a3204058aeffecb3$exports ( this . options . perMessageDeflate , true , this . options . maxPayload ) ; try { const offers = $d11422b22cc93234$require$parse ( req . headers [ 'sec-websocket-extensions' ] ) ; if ( offers [ $a3204058aeffecb3$exports . extensionName ] ) { perMessageDeflate . accept ( offers [ $a3204058aeffecb3$exports . extensionName ] ) ; extensions [ $a3204058aeffecb3$exports . extensionName ] = perMessageDeflate ; } } catch ( err ) { return $d11422b22cc93234$var$abortHandshake ( socket , 400 ) ; } } if ( this . options . verifyClient ) { const info = { origin : req . headers [ ` ${ version === 8 ? 'sec-websocket-origin' : 'origin' } ` ] , secure : ! ! ( req . socket . authorized || req . socket . encrypted ) , req : req } ; if ( this . options . verifyClient . length === 2 ) { this . options . verifyClient ( info , ( verified , code , message , headers ) => { if ( ! verified ) return $d11422b22cc93234$var$abortHandshake ( socket , code || 401 , message , headers ) ; this . completeUpgrade ( key , extensions , req , socket , head , cb ) ; } ) ; return ; } if ( ! this . options . verifyClient ( info ) ) return $d11422b22cc93234$var$abortHandshake ( socket , 401 ) ; } this . completeUpgrade ( key , extensions , req , socket , head , cb ) ; }
Handle a HTTP Upgrade request.
Handle a HTTP Upgrade request .
// // Optionally call external client verification handler. //