diff --git a/src/index.js b/src/index.js index 0457ac2..f19c44f 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ const YuFlux = require("./websocket"); const yuFlux = new YuFlux("http://localhost:8000"); -yuFlux.on("upgrade", (res, socket, head) => { - console.error("res.headers"); + +yuFlux.on("upgrade", (res) => { + console.error(res.headers, "res.headers"); }); diff --git a/src/websocket.js b/src/websocket.js index e044e2c..a3c630c 100644 --- a/src/websocket.js +++ b/src/websocket.js @@ -97,7 +97,7 @@ const initWebSocketClient = (websocket, address, protocols, options) => { const defaultPort = isSecure ? 443 : 80; opts.port = parseUrl.port || defaultPort; //处理ipv6 - opts.host = parseUrl.host.startsWith("[") ? parseUrl.host.slice(1, -1) : parseUrl.host; + opts.host = parseUrl.host.startsWith("[") ? parseUrl.hostName.slice(1, -1) : parseUrl.hostName; //请求头 opts.headers = { ...opts.headers,