Skip to content

Commit 1554a54

Browse files
author
Sergio Andres Virviescas Santana
committed
Merge branch 'master' of https://github.com/gorilla/websocket
2 parents 6c44d30 + b65e629 commit 1554a54

File tree

9 files changed

+21
-22
lines changed

9 files changed

+21
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This fork adds [fasthttp](https://github.com/valyala/fasthttp) support to the la
1212

1313
### Documentation
1414

15-
* [API Reference](http://godoc.org/github.com/fasthttp/websocket)
15+
* [API Reference](https://pkg.go.dev/github.com/fasthttp/websocket?tab=doc)
1616
* [Chat example](https://github.com/fasthttp/websocket/tree/master/examples/chat)
1717
* [Command example](https://github.com/fasthttp/websocket/tree/master/examples/command)
1818
* [Client and server example](https://github.com/fasthttp/websocket/tree/master/examples/echo)

client_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ func TestHost(t *testing.T) {
587587
server *httptest.Server // server to use
588588
url string // host for request URI
589589
header string // optional request host header
590-
tls string // optiona host for tls ServerName
590+
tls string // optional host for tls ServerName
591591
wantAddr string // expected host for dial
592592
wantHeader string // expected request header on server
593593
insecureSkipVerify bool

conn.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ type Conn struct {
244244
subprotocol string
245245

246246
// Write fields
247-
mu chan bool // used as mutex to protect write to conn
248-
writeBuf []byte // frame is constructed in this buffer.
247+
mu chan struct{} // used as mutex to protect write to conn
248+
writeBuf []byte // frame is constructed in this buffer.
249249
writePool BufferPool
250250
writeBufSize int
251251
writeDeadline time.Time
@@ -302,8 +302,8 @@ func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int,
302302
writeBuf = make([]byte, writeBufferSize)
303303
}
304304

305-
mu := make(chan bool, 1)
306-
mu <- true
305+
mu := make(chan struct{}, 1)
306+
mu <- struct{}{}
307307
c := &Conn{
308308
isServer: isServer,
309309
br: br,
@@ -377,7 +377,7 @@ func (c *Conn) read(n int) ([]byte, error) {
377377

378378
func (c *Conn) write(frameType int, deadline time.Time, buf0, buf1 []byte) error {
379379
<-c.mu
380-
defer func() { c.mu <- true }()
380+
defer func() { c.mu <- struct{}{} }()
381381

382382
c.writeErrMu.Lock()
383383
err := c.writeErr
@@ -429,7 +429,7 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
429429
maskBytes(key, 0, buf[6:])
430430
}
431431

432-
d := time.Hour * 1000
432+
d := 1000 * time.Hour
433433
if !deadline.IsZero() {
434434
d = deadline.Sub(time.Now())
435435
if d < 0 {
@@ -444,7 +444,7 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
444444
case <-timer.C:
445445
return errWriteTimeout
446446
}
447-
defer func() { c.mu <- true }()
447+
defer func() { c.mu <- struct{}{} }()
448448

449449
c.writeErrMu.Lock()
450450
err := c.writeErr

doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@
206206
// than the largest message do not provide any benefit.
207207
//
208208
// Depending on the distribution of message sizes, setting the buffer size to
209-
// to a value less than the maximum expected message size can greatly reduce
210-
// memory use with a small impact on performance. Here's an example: If 99% of
211-
// the messages are smaller than 256 bytes and the maximum message size is 512
209+
// a value less than the maximum expected message size can greatly reduce memory
210+
// use with a small impact on performance. Here's an example: If 99% of the
211+
// messages are smaller than 256 bytes and the maximum message size is 512
212212
// bytes, then a buffer size of 256 bytes will result in 1.01 more system calls
213213
// than a buffer size of 512 bytes. The memory savings is 50%.
214214
//

example_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ var (
2323
// This server application works with a client application running in the
2424
// browser. The client application does not explicitly close the websocket. The
2525
// only expected close message from the client has the code
26-
// websocket.CloseGoingAway. All other other close messages are likely the
26+
// websocket.CloseGoingAway. All other close messages are likely the
2727
// result of an application or protocol error and are logged to aid debugging.
2828
func ExampleIsUnexpectedCloseError() {
29-
3029
for {
3130
messageType, p, err := c.ReadMessage()
3231
if err != nil {
@@ -35,11 +34,11 @@ func ExampleIsUnexpectedCloseError() {
3534
}
3635
return
3736
}
38-
processMesage(messageType, p)
37+
processMessage(messageType, p)
3938
}
4039
}
4140

42-
func processMesage(mt int, p []byte) {}
41+
func processMessage(mt int, p []byte) {}
4342

4443
// TestX prevents godoc from showing this entire file in the example. Remove
4544
// this function when a second example is added.

examples/chat/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<div id="log"></div>
9393
<form id="form">
9494
<input type="submit" value="Send" />
95-
<input type="text" id="msg" size="64"/>
95+
<input type="text" id="msg" size="64" autofocus />
9696
</form>
9797
</body>
9898
</html>

examples/echo/fasthttp/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ window.addEventListener("load", function(evt) {
8181
8282
var print = function(message) {
8383
var d = document.createElement("div");
84-
d.innerHTML = message;
84+
d.textContent = message;
8585
output.appendChild(d);
8686
};
8787

examples/echo/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var homeTemplate = template.Must(template.New("").Parse(`
5858
<html>
5959
<head>
6060
<meta charset="utf-8">
61-
<script>
61+
<script>
6262
window.addEventListener("load", function(evt) {
6363
6464
var output = document.getElementById("output");
@@ -67,7 +67,7 @@ window.addEventListener("load", function(evt) {
6767
6868
var print = function(message) {
6969
var d = document.createElement("div");
70-
d.innerHTML = message;
70+
d.textContent = message;
7171
output.appendChild(d);
7272
};
7373

prepared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func (pm *PreparedMessage) frame(key prepareKey) (int, []byte, error) {
7373
// Prepare a frame using a 'fake' connection.
7474
// TODO: Refactor code in conn.go to allow more direct construction of
7575
// the frame.
76-
mu := make(chan bool, 1)
77-
mu <- true
76+
mu := make(chan struct{}, 1)
77+
mu <- struct{}{}
7878
var nc prepareConn
7979
c := &Conn{
8080
conn: &nc,

0 commit comments

Comments
 (0)