fix
This commit is contained in:
parent
75aacbcc65
commit
5c7d1bb6b0
|
@ -81,9 +81,10 @@ type wsConnectItem struct {
|
|||
// 请求建立连接,升级websocket协议
|
||||
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
|
||||
//把子协议携带的token设置到标准token头信息中
|
||||
r.Header.Set("Authorization", "Bearer "+r.Header.Get("Sec-Websocket-Protocol"))
|
||||
token := r.Header.Get("Sec-Websocket-Protocol")
|
||||
r.Header.Set("Authorization", "Bearer "+token)
|
||||
//设置Sec-Websocket-Protocol
|
||||
upgrade.Subprotocols = []string{r.Header.Get("Sec-Websocket-Protocol")}
|
||||
upgrade.Subprotocols = []string{token}
|
||||
//升级websocket
|
||||
conn, err := upgrade.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user