Skip to content

Commit 7c1bb91

Browse files
committed
up
1 parent c2d5e23 commit 7c1bb91

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type (
9797

9898
// WebSocket子协议, 握手失败会断开连接
9999
// WebSocket sub-protocol, handshake failure disconnects the connection
100-
Subprotocols []string
100+
SubProtocols []string
101101

102102
// 额外的响应头(可能不受客户端支持)
103103
// Additional response headers (may not be supported by the client)

option_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestDefaultUpgrader(t *testing.T) {
6363
as.NotNil(updrader.option.ResponseHeader)
6464
as.NotNil(updrader.option.Authorize)
6565
as.NotNil(updrader.option.NewSessionStorage)
66-
as.Nil(updrader.option.Subprotocols)
66+
as.Nil(updrader.option.SubProtocols)
6767
validateServerOption(as, updrader)
6868
}
6969

updrader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func NewUpgrader(eventHandler Event, option *ServerOption) *Upgrader {
2626
}
2727

2828
func (c *Upgrader) connectHandshake(r *http.Request, responseHeader http.Header, conn net.Conn, websocketKey string) (subprotocol string, err error) {
29-
if len(c.option.Subprotocols) > 0 {
30-
subprotocol = internal.GetIntersectionElem(internal.Split(r.Header.Get(internal.SecWebSocketProtocol.Key), ","), c.option.Subprotocols)
29+
if len(c.option.SubProtocols) > 0 {
30+
subprotocol = internal.GetIntersectionElem(internal.Split(r.Header.Get(internal.SecWebSocketProtocol.Key), ","), c.option.SubProtocols)
3131
if subprotocol == "" {
3232
return "", ErrHandshake
3333
}

upgrader_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func TestAccept(t *testing.T) {
111111

112112
t.Run("ok", func(t *testing.T) {
113113
upgrader.option.CompressEnabled = true
114-
upgrader.option.Subprotocols = []string{"chat"}
114+
upgrader.option.SubProtocols = []string{"chat"}
115115
var request = &http.Request{
116116
Header: http.Header{},
117117
Method: http.MethodGet,
@@ -325,7 +325,7 @@ func TestBuiltinEventEngine(t *testing.T) {
325325
func TestSubprotocol(t *testing.T) {
326326
t.Run("server close", func(t *testing.T) {
327327
var addr = "127.0.0.1:" + nextPort()
328-
app := NewServer(new(BuiltinEventHandler), &ServerOption{Subprotocols: []string{"chat"}})
328+
app := NewServer(new(BuiltinEventHandler), &ServerOption{SubProtocols: []string{"chat"}})
329329
go func() { app.Run(addr) }()
330330

331331
time.Sleep(100 * time.Millisecond)
@@ -350,7 +350,7 @@ func TestSubprotocol(t *testing.T) {
350350

351351
t.Run("ok", func(t *testing.T) {
352352
var addr = "127.0.0.1:" + nextPort()
353-
app := NewServer(new(BuiltinEventHandler), &ServerOption{Subprotocols: []string{"chat"}})
353+
app := NewServer(new(BuiltinEventHandler), &ServerOption{SubProtocols: []string{"chat"}})
354354
go func() { app.Run(addr) }()
355355

356356
time.Sleep(100 * time.Millisecond)

0 commit comments

Comments
 (0)