| build: add Makefile (#525) | 1 year ago |
| build: add Makefile (#525) | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| docs: add document for AI agents (AGENTS.md) (#547) | 9 months ago |
| docs: fix lint issue (#557) | 8 months ago |
| chore: update LICENSE file (#526) | 1 year ago |
| build: add Makefile (#525) | 1 year ago |
| docs: fix roadmap links (#558) | 7 months ago |
| chore: fix typo in Accept function (#544) | 11 months ago |
| fix: match Origin scheme if defined in OriginPatterns (#536) This change aligns origin checks with RFC 6454 by adding scheme-aware matching to OriginPatterns. Fixes #529 | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| refactor: use `context.AfterFunc` to track timeouts instead of goroutine (#532) Closes #411 Closes #501 | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| fix: transmit in single frame when compression enabled (#552) Closes https://github.com/coder/websocket/issues/435 When compression was enabled, `Conn.Write` sent messages across many small frames due to the flate library's internal `bufferFlushSize` (240 bytes). Each flush triggered a `writeFrame` call, producing alternating ~236 and 4 byte frames. `Conn.Write` now compresses the entire message into a buffer first, then transmits it as a single frame. Messages below `flateThreshold` bypass compression and are sent uncompressed in a single frame. | 10 months ago |
| conn: skip timeout callbacks for background contexts (#566) Every frame read and write registered a context.AfterFunc callback so a context cancellation could close the connection. context.Background cannot be canceled because its Done channel is nil, but the code still constructed, stored, stopped, and cleared a callback registration for each operation. Skip that work when ctx.Done() is nil, and only clear a timeout when one was actually installed. BenchmarkConn also joins its writer goroutine after timing so repeated benchmark runs finish cleanly. The results below compare parent 70393646 with this commit on an Apple M4 Max using GOMAXPROCS=1 over 10 samples. A temporary in-package harness, not included in this commit, repeatedly called one internal frame read using either context.Background or an uncanceled context.WithCancel. Header reads parse a minimal frame header; payload reads copy 512 bytes from a buffered repeating reader. Before this change, setupReadTimeout called context.AfterFunc even for context.Background. Avoiding that dead registration reduces background header reads from 121.95 to 29.94 ns/op and payload reads from 124.17 to 29.15 ns/op. Both fall from 152 B/op and 4 allocs/op to zero. Cancelable contexts still need an AfterFunc registration, so they remain at 152 B/op and 4 allocs/op. BenchmarkConn/disabledCompress uses a cancelable context as well, so it remains at 1219 B/op and 32 allocs/op. | 4 months ago |
| conn: skip timeout callbacks for background contexts (#566) Every frame read and write registered a context.AfterFunc callback so a context cancellation could close the connection. context.Background cannot be canceled because its Done channel is nil, but the code still constructed, stored, stopped, and cleared a callback registration for each operation. Skip that work when ctx.Done() is nil, and only clear a timeout when one was actually installed. BenchmarkConn also joins its writer goroutine after timing so repeated benchmark runs finish cleanly. The results below compare parent 70393646 with this commit on an Apple M4 Max using GOMAXPROCS=1 over 10 samples. A temporary in-package harness, not included in this commit, repeatedly called one internal frame read using either context.Background or an uncanceled context.WithCancel. Header reads parse a minimal frame header; payload reads copy 512 bytes from a buffered repeating reader. Before this change, setupReadTimeout called context.AfterFunc even for context.Background. Avoiding that dead registration reduces background header reads from 121.95 to 29.94 ns/op and payload reads from 124.17 to 29.15 ns/op. Both fall from 152 B/op and 4 allocs/op to zero. Cancelable contexts still need an AfterFunc registration, so they remain at 152 B/op and 4 allocs/op. BenchmarkConn/disabledCompress uses a cancelable context as well, so it remains at 1219 B/op and 32 allocs/op. | 4 months ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| refactor: add `ErrMessageTooBig` sentinel error for limited reads (#535) --------- Co-authored-by: Mathias Fredriksson <mafredri@gmail.com> | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| Update import path to github.com/coder/websocket This will create easily solved breakage on updates but I figure it's best to pull the band aid off as early as possible | 2 years ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| build: update to Go 1.23 (#524) * build: update to Go 1.23 * ci: update tools | 1 year ago |
| internal/xcpu: Vendor golang.org/x/sys/cpu Standard library does this too. Unfortunate wish they just exposed it in the standard library. Perhaps we can isolate the specific code we need later. | 2 years ago |
| accept: Add unwrapping for hijack like http.ResponseController (#472) Since we rely on the connection not being hijacked too early (i.e. detecting the presence of http.Hijacker) to set headers, we must manually implement the unwrapping of the http.ResponseController. By doing so, we also retain Go 1.19 compatibility without build tags. Closes #455 | 2 years ago |
| accept: Add unwrapping for hijack like http.ResponseController (#472) Since we rely on the connection not being hijacked too early (i.e. detecting the presence of http.Hijacker) to set headers, we must manually implement the unwrapping of the http.ResponseController. By doing so, we also retain Go 1.19 compatibility without build tags. Closes #455 | 2 years ago |
| Ensure no goroutines leak after Close Closes #330 | 3 years ago |
| mask_asm: Disable for now until v1.9.0 See #326 | 2 years ago |
| mask_asm: Disable AVX2 See https://github.com/nhooyr/websocket/pull/326#issuecomment-1771138049 | 2 years ago |
| mask_asm: Note implementation may not be perfect | 2 years ago |
| read: Fix CloseRead to have its own done channel Context can be cancelled by parent. Doesn't indicate the CloseRead goroutine has exited. | 2 years ago |
| mask.go: Revert my changes I'm just not good enough at assembly. I added tests to confirm that @wdvxdr's implementation works correctly and matches the output of the basic masking loop. | 2 years ago |
| mask.go: Reorganize | 2 years ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| netconn.go: Return real remote and local address where possible | 3 years ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |
| conn: skip timeout callbacks for background contexts (#566) Every frame read and write registered a context.AfterFunc callback so a context cancellation could close the connection. context.Background cannot be canceled because its Done channel is nil, but the code still constructed, stored, stopped, and cleared a callback registration for each operation. Skip that work when ctx.Done() is nil, and only clear a timeout when one was actually installed. BenchmarkConn also joins its writer goroutine after timing so repeated benchmark runs finish cleanly. The results below compare parent 70393646 with this commit on an Apple M4 Max using GOMAXPROCS=1 over 10 samples. A temporary in-package harness, not included in this commit, repeatedly called one internal frame read using either context.Background or an uncanceled context.WithCancel. Header reads parse a minimal frame header; payload reads copy 512 bytes from a buffered repeating reader. Before this change, setupReadTimeout called context.AfterFunc even for context.Background. Avoiding that dead registration reduces background header reads from 121.95 to 29.94 ns/op and payload reads from 124.17 to 29.15 ns/op. Both fall from 152 B/op and 4 allocs/op to zero. Cancelable contexts still need an AfterFunc registration, so they remain at 152 B/op and 4 allocs/op. BenchmarkConn/disabledCompress uses a cancelable context as well, so it remains at 1219 B/op and 32 allocs/op. | 4 months ago |
| Change websocket to WebSocket in docs/errors | 6 years ago |
| conn: skip timeout callbacks for background contexts (#566) Every frame read and write registered a context.AfterFunc callback so a context cancellation could close the connection. context.Background cannot be canceled because its Done channel is nil, but the code still constructed, stored, stopped, and cleared a callback registration for each operation. Skip that work when ctx.Done() is nil, and only clear a timeout when one was actually installed. BenchmarkConn also joins its writer goroutine after timing so repeated benchmark runs finish cleanly. The results below compare parent 70393646 with this commit on an Apple M4 Max using GOMAXPROCS=1 over 10 samples. A temporary in-package harness, not included in this commit, repeatedly called one internal frame read using either context.Background or an uncanceled context.WithCancel. Header reads parse a minimal frame header; payload reads copy 512 bytes from a buffered repeating reader. Before this change, setupReadTimeout called context.AfterFunc even for context.Background. Avoiding that dead registration reduces background header reads from 121.95 to 29.94 ns/op and payload reads from 124.17 to 29.15 ns/op. Both fall from 152 B/op and 4 allocs/op to zero. Cancelable contexts still need an AfterFunc registration, so they remain at 152 B/op and 4 allocs/op. BenchmarkConn/disabledCompress uses a cancelable context as well, so it remains at 1219 B/op and 32 allocs/op. | 4 months ago |
| refactor: add `ErrMessageTooBig` sentinel error for limited reads (#535) --------- Co-authored-by: Mathias Fredriksson <mafredri@gmail.com> | 1 year ago |
| chore: apply various modernisations (#531) * Use any instead of interface{} given Go > 1.18 * Minor tidies thanks to gofumpt * Run "go fix ./..." on the codebase * Apply a few modernisations suggested by gopls check * Remove unused parameter suggested by gopls check | 1 year ago |