The package ignored errors from net.Conn Set*Deadline in a few places.
Update the package to return these errors to the caller.
Ignore all other errors reported by errcheck. These errors are safe to
ignore because
- The function is making a best effort to cleanup while handling another
error.
- The function call is guaranteed to succeed.
- The error is ignored in a test.
See https://go.dev/issue/45729.
- Remove hideTempError
The hideTempError function was used to prevent connection methods from
returning a net.Error with Temporary() == true.
Connection methods do not support retry after returning any net.Error,
including errors with Temporary() == true.
Presumably hideTempError was used to prevent applications from
futilely retrying connection method calls on temporary errors.
The hideTempError function is not needed now that net.Error
Temporary() is deprecated.
- Remove use of the deprecated net.Error Temporary() method in the
default ping handler by ignoring all errors returned from
WriteControl. Ignoring errors allows the application to continue
reading messages after a write error and is consistent with how the
default close handler calls WriteControl.
The doHandshake function was split off to separate files to support
different implementations for Go < 1.16 and Go >= 1.17.
The separate files are not needed now that Go 1.20 is the minimum
supported version of Go for the project.
Use Reader.Size() (add in Go 1.10) to get the bufio.Reader's size
instead of examining the return value from Reader.Peek.
Use Writer.AvailableBuffer() (added in Go 1.18) to get the
bufio.Writer's buffer instead of observing the buffer in the underlying
writer.
Allow client to send data before the handshake is complete. Previously,
Upgrader.Upgrade rudely closed the connection.
Import golang.org/x/net/proxy instead of using the bundle in
x_net_proxy.go. There's no need to avoid the dependency on
golang.org/x/net/proxy now that Go's module system is in widespread use.
Change Dialer.DialContext to pass contexts as an argument to the dial
function instead of tunneling the context through closures. Tunneling is
no longer needed because the proxy package supports contexts. The
version of the proxy package in the bundle predates contexts!
Simplify the code for calculating the base dial function.
Prevent the HTTP proxy dialer from leaking out of the websocket package
by selecting the HTTP proxy dialer directly in the websocket package.
Previously, the HTTP dialer was registered with the proxy package.
Tests must not call *testing.T methods after the test function returns.
Use a sync.WaitGroup to ensure that server handler functions complete
before tests return.
Maintainers accidentally changed the reference commit
for v1.5.2. This change retracts v1.5.2 which also
includes a number of avoidable issues.
Fixes#927
A zero value for the Conn.WriteControl deadline specifies no timeout,
but the feature was implemented as a very long timeout (1000 hours).
This PR updates the code to use no timeout when the deadline is zero.
See the discussion in #895 for more details.
The 666c197 added an error handling in `SetCloseHandler()` and peer
stops getting `CloseError` when network issue like `write: broken
pipe` happens because the close handle returns the error.
Hence this patch changes to skip network error handling.
### summary
😅 Every time I use `gorilla/websocket`, I need to look at the source
code and find the default size for readBufferSize and writeBufferSize.
I think the default value should be written in the comment.
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Co-authored-by: Alex Vulaj <ajvulaj@gmail.com>