Skip to content

Commit 5f76559

Browse files
committed
Fix CI
Hopefully this time things work.
1 parent 0d59d7f commit 5f76559

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

.github/lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -euxo pipefail
3+
set -euxo pipefail || exit 1
44

55
export GO111MODULE=on
66
export PAGER=cat

accept.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ type acceptSubprotocols []string
2222

2323
func (o acceptSubprotocols) acceptOption() {}
2424

25-
// AcceptProtocols lists the websocket protocols that Accept will negotiate with a client.
26-
// The empty protocol will always be negotiated as per RFC 6455. If you would like to
25+
// AcceptSubprotocols lists the websocket subprotocols that Accept will negotiate with a client.
26+
// The empty subprotocol will always be negotiated as per RFC 6455. If you would like to
2727
// reject it, close the connection if c.Subprotocol() == "".
28-
func AcceptProtocols(subprotocols ...string) AcceptOption {
29-
return acceptSubprotocols(subprotocols)
28+
func AcceptSubprotocols(protocols ...string) AcceptOption {
29+
return acceptSubprotocols(protocols)
3030
}
3131

3232
type acceptOrigins []string
3333

3434
func (o acceptOrigins) acceptOption() {}
3535

3636
// AcceptOrigins lists the origins that Accept will accept.
37-
// Accept will always accept r.Host as the origin so you do not need to
38-
// specify that with this option.
37+
// Accept will always accept r.Host as the origin. Use this
38+
// option when you want to accept an origin with a different domain
39+
// than the one the WebSocket server is running on.
3940
//
4041
// Use this option with caution to avoid exposing your WebSocket
4142
// server to a CSRF attack.
4243
// See https://stackoverflow.com/a/37837709/4283659
43-
// You can use a * for wildcards.
4444
func AcceptOrigins(origins ...string) AcceptOption {
4545
return acceptOrigins(origins)
4646
}

websocket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (c *Conn) close(err error) {
7070

7171
// Subprotocol returns the negotiated subprotocol.
7272
// An empty string means the default protocol.
73-
func (c *Conn) Protocol() string {
73+
func (c *Conn) Subprotocol() string {
7474
return c.subprotocol
7575
}
7676

websocket_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestHandshake(t *testing.T) {
3434
{
3535
name: "handshake",
3636
server: func(w http.ResponseWriter, r *http.Request) error {
37-
c, err := websocket.Accept(w, r, websocket.AcceptProtocols("myproto"))
37+
c, err := websocket.Accept(w, r, websocket.AcceptSubprotocols("myproto"))
3838
if err != nil {
3939
return err
4040
}
@@ -74,8 +74,8 @@ func TestHandshake(t *testing.T) {
7474
}
7575
defer c.Close(websocket.StatusInternalError, "")
7676

77-
if c.Protocol() != "" {
78-
return xerrors.Errorf("unexpected subprotocol: %v", c.Protocol())
77+
if c.Subprotocol() != "" {
78+
return xerrors.Errorf("unexpected subprotocol: %v", c.Subprotocol())
7979
}
8080
return nil
8181
},
@@ -86,23 +86,23 @@ func TestHandshake(t *testing.T) {
8686
}
8787
defer c.Close(websocket.StatusInternalError, "")
8888

89-
if c.Protocol() != "" {
90-
return xerrors.Errorf("unexpected subprotocol: %v", c.Protocol())
89+
if c.Subprotocol() != "" {
90+
return xerrors.Errorf("unexpected subprotocol: %v", c.Subprotocol())
9191
}
9292
return nil
9393
},
9494
},
9595
{
9696
name: "subprotocol",
9797
server: func(w http.ResponseWriter, r *http.Request) error {
98-
c, err := websocket.Accept(w, r, websocket.AcceptProtocols("echo", "lar"))
98+
c, err := websocket.Accept(w, r, websocket.AcceptSubprotocols("echo", "lar"))
9999
if err != nil {
100100
return err
101101
}
102102
defer c.Close(websocket.StatusInternalError, "")
103103

104-
if c.Protocol() != "echo" {
105-
return xerrors.Errorf("unexpected subprotocol: %q", c.Protocol())
104+
if c.Subprotocol() != "echo" {
105+
return xerrors.Errorf("unexpected subprotocol: %q", c.Subprotocol())
106106
}
107107
return nil
108108
},
@@ -113,8 +113,8 @@ func TestHandshake(t *testing.T) {
113113
}
114114
defer c.Close(websocket.StatusInternalError, "")
115115

116-
if c.Protocol() != "echo" {
117-
return xerrors.Errorf("unexpected subprotocol: %q", c.Protocol())
116+
if c.Subprotocol() != "echo" {
117+
return xerrors.Errorf("unexpected subprotocol: %q", c.Subprotocol())
118118
}
119119
return nil
120120
},
@@ -266,7 +266,7 @@ func TestAutobahnServer(t *testing.T) {
266266

267267
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
268268
c, err := websocket.Accept(w, r,
269-
websocket.AcceptProtocols("echo"),
269+
websocket.AcceptSubprotocols("echo"),
270270
)
271271
if err != nil {
272272
t.Logf("server handshake failed: %+v", err)

0 commit comments

Comments
 (0)