fix
This commit is contained in:
parent
41caa6db64
commit
a72aa2feca
|
@ -45,7 +45,7 @@ var (
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
//升级websocket
|
//升级websocket
|
||||||
upgrade = websocket.Upgrader{
|
upgrader = websocket.Upgrader{
|
||||||
//最大可读取大小 10M
|
//最大可读取大小 10M
|
||||||
ReadBufferSize: 1024 * 10,
|
ReadBufferSize: 1024 * 10,
|
||||||
//握手超时时间15s
|
//握手超时时间15s
|
||||||
|
@ -86,9 +86,9 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
|
||||||
token := r.Header.Get("Sec-Websocket-Protocol")
|
token := r.Header.Get("Sec-Websocket-Protocol")
|
||||||
r.Header.Set("Authorization", "Bearer "+token)
|
r.Header.Set("Authorization", "Bearer "+token)
|
||||||
//设置Sec-Websocket-Protocol
|
//设置Sec-Websocket-Protocol
|
||||||
upgrade.Subprotocols = []string{token}
|
upgrader.Subprotocols = []string{token}
|
||||||
//升级websocket
|
//升级websocket
|
||||||
conn, err := upgrade.Upgrade(w, r, nil)
|
conn, err := upgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error("http upgrade websocket err:", err)
|
logx.Error("http upgrade websocket err:", err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user