Skip to content

Commit badaab8

Browse files
chore: fork to scalecode-solutions and modernize to Go 1.26
Foundation commit for the personal fork. No behavior change beyond what the Go toolchain and std-lib bumps imply. Module & toolchain * Rewrite module path to github.com/scalecode-solutions/websocket across go.mod, README, examples, and import statements. * Bump language version from 1.20 -> 1.26 (matches local toolchain). * Bump golang.org/x/net from v0.26.0 -> v0.53.0, closing the path flagged by upstream issue #991 (HTTP/2 CVEs in older x/net). Hygiene (small, mechanical) * interface{} -> any across compression.go, conn.go, conn_test.go, and json.go (upstream PR #1000). BufferPool interface signature changes are source-compatible since any is an alias. * Fix "best effor" -> "best effort" and "buferred" -> "buffered" typos in conn.go and server.go (upstream PR #975, carried in PR #1011). * Add the missing blank line before the Deprecated: marker on UnderlyingConn so godoc/linters treat it as deprecated (upstream PR #998). * Extend the DialContext godoc to note that non-101 responses produce an error (upstream PR #965). Drop pre-1.21 compat cruft * Delete mask_safe.go and the !appengine build tags. Classic App Engine required a sandboxed Go runtime without unsafe; it was retired in 2020 and modern App Engine uses the standard toolchain. * Drop legacy `// +build` lines (Go 1.18+ only needs //go:build). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e064f32 commit badaab8

22 files changed

Lines changed: 49 additions & 74 deletions

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Gorilla WebSocket
22

3-
[![GoDoc](https://godoc.org/github.com/gorilla/websocket?status.svg)](https://godoc.org/github.com/gorilla/websocket)
3+
[![GoDoc](https://godoc.org/github.com/scalecode-solutions/websocket?status.svg)](https://godoc.org/github.com/scalecode-solutions/websocket)
44
[![CircleCI](https://circleci.com/gh/gorilla/websocket.svg?style=svg)](https://circleci.com/gh/gorilla/websocket)
55

66
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
@@ -9,11 +9,11 @@ Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
99

1010
### Documentation
1111

12-
* [API Reference](https://pkg.go.dev/github.com/gorilla/websocket?tab=doc)
13-
* [Chat example](https://github.com/gorilla/websocket/tree/main/examples/chat)
14-
* [Command example](https://github.com/gorilla/websocket/tree/main/examples/command)
15-
* [Client and server example](https://github.com/gorilla/websocket/tree/main/examples/echo)
16-
* [File watch example](https://github.com/gorilla/websocket/tree/main/examples/filewatch)
12+
* [API Reference](https://pkg.go.dev/github.com/scalecode-solutions/websocket?tab=doc)
13+
* [Chat example](https://github.com/scalecode-solutions/websocket/tree/main/examples/chat)
14+
* [Command example](https://github.com/scalecode-solutions/websocket/tree/main/examples/command)
15+
* [Client and server example](https://github.com/scalecode-solutions/websocket/tree/main/examples/echo)
16+
* [File watch example](https://github.com/scalecode-solutions/websocket/tree/main/examples/filewatch)
1717

1818
### Status
1919

@@ -23,10 +23,10 @@ package API is stable.
2323

2424
### Installation
2525

26-
go get github.com/gorilla/websocket
26+
go get github.com/scalecode-solutions/websocket
2727

2828
### Protocol Compliance
2929

3030
The Gorilla WebSocket package passes the server tests in the [Autobahn Test
3131
Suite](https://github.com/crossbario/autobahn-testsuite) using the application in the [examples/autobahn
32-
subdirectory](https://github.com/gorilla/websocket/tree/main/examples/autobahn).
32+
subdirectory](https://github.com/scalecode-solutions/websocket/tree/main/examples/autobahn).

client.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var errInvalidCompression = errors.New("websocket: invalid compression negotiati
3333
//
3434
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
3535
// non-nil *http.Response so that callers can handle redirects, authentication,
36-
// etc.
36+
// etc. All non-101 response codes result in an error.
3737
//
3838
// Deprecated: Use Dialer instead.
3939
func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) {
@@ -170,8 +170,9 @@ var nilDialer = *DefaultDialer
170170
//
171171
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
172172
// non-nil *http.Response so that callers can handle redirects, authentication,
173-
// etcetera. The response body may not contain the entire response and does not
174-
// need to be closed by the application.
173+
// etcetera. All non-101 response codes result in an error. The response body
174+
// may not contain the entire response and does not need to be closed by the
175+
// application.
175176
func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
176177
if d == nil {
177178
d = &nilDialer

compression.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020

2121
var (
2222
flateWriterPools [maxCompressionLevel - minCompressionLevel + 1]sync.Pool
23-
flateReaderPool = sync.Pool{New: func() interface{} {
23+
flateReaderPool = sync.Pool{New: func() any {
2424
return flate.NewReader(nil)
2525
}}
2626
)

conn.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ func isValidReceivedCloseCode(code int) bool {
227227
// interface. The type of the value stored in a pool is not specified.
228228
type BufferPool interface {
229229
// Get gets a value from the pool or returns nil if the pool is empty.
230-
Get() interface{}
230+
Get() any
231231
// Put adds a value to the pool.
232-
Put(interface{})
232+
Put(any)
233233
}
234234

235235
// writePoolData is the type added to the write buffer pool. This wrapper is
@@ -991,7 +991,7 @@ func (c *Conn) handleProtocolError(message string) error {
991991
if len(data) > maxControlFramePayloadSize {
992992
data = data[:maxControlFramePayloadSize]
993993
}
994-
// Make a best effor to send a close message describing the problem.
994+
// Make a best effort to send a close message describing the problem.
995995
_ = c.WriteControl(CloseMessage, data, time.Now().Add(writeWait))
996996
return errors.New("websocket: " + message)
997997
}
@@ -1147,7 +1147,7 @@ func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
11471147
if h == nil {
11481148
h = func(code int, text string) error {
11491149
message := FormatCloseMessage(code, "")
1150-
// Make a best effor to send the close message.
1150+
// Make a best effort to send the close message.
11511151
_ = c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
11521152
return nil
11531153
}
@@ -1206,6 +1206,7 @@ func (c *Conn) NetConn() net.Conn {
12061206

12071207
// UnderlyingConn returns the internal net.Conn. This can be used to further
12081208
// modifications to connection specific flags.
1209+
//
12091210
// Deprecated: Use the NetConn method.
12101211
func (c *Conn) UnderlyingConn() net.Conn {
12111212
return c.conn

conn_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,16 @@ func TestControl(t *testing.T) {
227227

228228
// simpleBufferPool is an implementation of BufferPool for TestWriteBufferPool.
229229
type simpleBufferPool struct {
230-
v interface{}
230+
v any
231231
}
232232

233-
func (p *simpleBufferPool) Get() interface{} {
233+
func (p *simpleBufferPool) Get() any {
234234
v := p.v
235235
p.v = nil
236236
return v
237237
}
238238

239-
func (p *simpleBufferPool) Put(v interface{}) {
239+
func (p *simpleBufferPool) Put(v any) {
240240
p.v = v
241241
}
242242

example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"testing"
1111

12-
"github.com/gorilla/websocket"
12+
"github.com/scalecode-solutions/websocket"
1313
)
1414

1515
var (

examples/autobahn/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"time"
1515
"unicode/utf8"
1616

17-
"github.com/gorilla/websocket"
17+
"github.com/scalecode-solutions/websocket"
1818
)
1919

2020
var upgrader = websocket.Upgrader{

examples/chat/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Chat Example
22

33
This application shows how to use the
4-
[websocket](https://github.com/gorilla/websocket) package to implement a simple
4+
[websocket](https://github.com/scalecode-solutions/websocket) package to implement a simple
55
web chat application.
66

77
## Running the example
@@ -13,8 +13,8 @@ development environment.
1313
Once you have Go up and running, you can download, build and run the example
1414
using the following commands.
1515

16-
$ go get github.com/gorilla/websocket
17-
$ cd `go list -f '{{.Dir}}' github.com/gorilla/websocket/examples/chat`
16+
$ go get github.com/scalecode-solutions/websocket
17+
$ cd `go list -f '{{.Dir}}' github.com/scalecode-solutions/websocket/examples/chat`
1818
$ go run *.go
1919

2020
To use the chat example, open http://localhost:8080/ in your browser.
@@ -38,7 +38,7 @@ sends them to the hub.
3838
### Hub
3939

4040
The code for the `Hub` type is in
41-
[hub.go](https://github.com/gorilla/websocket/blob/main/examples/chat/hub.go).
41+
[hub.go](https://github.com/scalecode-solutions/websocket/blob/main/examples/chat/hub.go).
4242
The application's `main` function starts the hub's `run` method as a goroutine.
4343
Clients send requests to the hub using the `register`, `unregister` and
4444
`broadcast` channels.
@@ -57,7 +57,7 @@ unregisters the client and closes the websocket.
5757

5858
### Client
5959

60-
The code for the `Client` type is in [client.go](https://github.com/gorilla/websocket/blob/main/examples/chat/client.go).
60+
The code for the `Client` type is in [client.go](https://github.com/scalecode-solutions/websocket/blob/main/examples/chat/client.go).
6161

6262
The `serveWs` function is registered by the application's `main` function as
6363
an HTTP handler. The handler upgrades the HTTP connection to the WebSocket
@@ -73,7 +73,7 @@ Finally, the HTTP handler calls the client's `readPump` method. This method
7373
transfers inbound messages from the websocket to the hub.
7474

7575
WebSocket connections [support one concurrent reader and one concurrent
76-
writer](https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency). The
76+
writer](https://godoc.org/github.com/scalecode-solutions/websocket#hdr-Concurrency). The
7777
application ensures that these concurrency requirements are met by executing
7878
all reads from the `readPump` goroutine and all writes from the `writePump`
7979
goroutine.
@@ -85,7 +85,7 @@ network.
8585

8686
## Frontend
8787

88-
The frontend code is in [home.html](https://github.com/gorilla/websocket/blob/main/examples/chat/home.html).
88+
The frontend code is in [home.html](https://github.com/scalecode-solutions/websocket/blob/main/examples/chat/home.html).
8989

9090
On document load, the script checks for websocket functionality in the browser.
9191
If websocket functionality is available, then the script opens a connection to

examples/chat/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/http"
1111
"time"
1212

13-
"github.com/gorilla/websocket"
13+
"github.com/scalecode-solutions/websocket"
1414
)
1515

1616
const (

examples/command/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This example connects a websocket connection to stdin and stdout of a command.
44
Received messages are written to stdin followed by a `\n`. Each line read from
55
standard out is sent as a message to the client.
66

7-
$ go get github.com/gorilla/websocket
8-
$ cd `go list -f '{{.Dir}}' github.com/gorilla/websocket/examples/command`
7+
$ go get github.com/scalecode-solutions/websocket
8+
$ cd `go list -f '{{.Dir}}' github.com/scalecode-solutions/websocket/examples/command`
99
$ go run main.go <command and arguments to run>
1010
# Open http://localhost:8080/ .
1111

0 commit comments

Comments
 (0)