我的目标是, 当与客户端建立连接时, 发送一个cookie到客户端去, 必须在这个wss里, 不能使用普通http方法.
我是这么调用的:
var responseHeader http.Header
//这里我不知道怎么写了
// responseHeader.Set("Set-Cookie", "SS=Q0=5Lb_nQ; path=/search")
var conn, err = upgrader.Upgrade(w, r, responseHeader)
方法的原型是这样的
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
//
// The responseHeader is included in the response to the client's upgrade
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
// application negotiated subprotocol (Sec-WebSocket-Protocol).
//
// If the upgrade fails, then Upgrade replies to the client with an HTTP error
// response.
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
const badHandshake = "websocket: the client is not using the websocket protocol: "