Compare commits

..

No commits in common. "39f5f1c5358efc1999c3ff37d0d7c8130ce1731a" and "4378cca2518bb8a278c5b0ff17b3f4222409c806" have entirely different histories.

10 changed files with 24 additions and 21 deletions

View File

@ -67,4 +67,4 @@ workflows:
- test:
matrix:
parameters:
version: ["1.22", "1.21", "1.20"]
version: ["1.18", "1.17", "1.16"]

View File

@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httptrace"
@ -399,7 +400,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
// debugging.
buf := make([]byte, 1024)
n, _ := io.ReadFull(resp.Body, buf)
resp.Body = io.NopCloser(bytes.NewReader(buf[:n]))
resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n]))
return nil, resp, ErrBadHandshake
}
@ -417,7 +418,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
break
}
resp.Body = io.NopCloser(bytes.NewReader([]byte{}))
resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol")
netConn.SetDeadline(time.Time{})

View File

@ -14,6 +14,7 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"net/http"
@ -548,7 +549,7 @@ func TestRespOnBadHandshake(t *testing.T) {
t.Errorf("resp.StatusCode=%d, want %d", resp.StatusCode, expectedStatus)
}
p, err := io.ReadAll(resp.Body)
p, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatalf("ReadFull(resp.Body) returned error %v", err)
}

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"testing"
)
@ -41,7 +42,7 @@ func textMessages(num int) [][]byte {
}
func BenchmarkWriteNoCompression(b *testing.B) {
w := io.Discard
w := ioutil.Discard
c := newTestConn(nil, w, false)
messages := textMessages(100)
b.ResetTimer()
@ -52,7 +53,7 @@ func BenchmarkWriteNoCompression(b *testing.B) {
}
func BenchmarkWriteWithCompression(b *testing.B) {
w := io.Discard
w := ioutil.Discard
c := newTestConn(nil, w, false)
messages := textMessages(100)
c.enableWriteCompression = true

View File

@ -9,6 +9,7 @@ import (
"encoding/binary"
"errors"
"io"
"io/ioutil"
"math/rand"
"net"
"strconv"
@ -794,7 +795,7 @@ func (c *Conn) advanceFrame() (int, error) {
// 1. Skip remainder of previous frame.
if c.readRemaining > 0 {
if _, err := io.CopyN(io.Discard, c.br, c.readRemaining); err != nil {
if _, err := io.CopyN(ioutil.Discard, c.br, c.readRemaining); err != nil {
return noFrame, err
}
}
@ -1093,7 +1094,7 @@ func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
if err != nil {
return messageType, nil, err
}
p, err = io.ReadAll(r)
p, err = ioutil.ReadAll(r)
return messageType, p, err
}

View File

@ -6,6 +6,7 @@ package websocket
import (
"io"
"io/ioutil"
"sync/atomic"
"testing"
)
@ -44,7 +45,7 @@ func newBroadcastConn(c *Conn) *broadcastConn {
func newBroadcastBench(usePrepared, compression bool) *broadcastBench {
bench := &broadcastBench{
w: io.Discard,
w: ioutil.Discard,
doneCh: make(chan struct{}),
closeCh: make(chan struct{}),
usePrepared: usePrepared,

View File

@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"reflect"
"sync"
@ -124,7 +125,7 @@ func TestFraming(t *testing.T) {
}
t.Logf("frame size: %d", n)
rbuf, err := io.ReadAll(r)
rbuf, err := ioutil.ReadAll(r)
if err != nil {
t.Errorf("%s: ReadFull() returned rbuf, %v", name, err)
continue
@ -366,7 +367,7 @@ func TestCloseFrameBeforeFinalMessageFrame(t *testing.T) {
if op != BinaryMessage || err != nil {
t.Fatalf("NextReader() returned %d, %v", op, err)
}
_, err = io.Copy(io.Discard, r)
_, err = io.Copy(ioutil.Discard, r)
if !reflect.DeepEqual(err, expectedErr) {
t.Fatalf("io.Copy() returned %v, want %v", err, expectedErr)
}
@ -400,7 +401,7 @@ func TestEOFWithinFrame(t *testing.T) {
if op != BinaryMessage || err != nil {
t.Fatalf("%d: NextReader() returned %d, %v", n, op, err)
}
_, err = io.Copy(io.Discard, r)
_, err = io.Copy(ioutil.Discard, r)
if err != errUnexpectedEOF {
t.Fatalf("%d: io.Copy() returned %v, want %v", n, err, errUnexpectedEOF)
}
@ -425,7 +426,7 @@ func TestEOFBeforeFinalFrame(t *testing.T) {
if op != BinaryMessage || err != nil {
t.Fatalf("NextReader() returned %d, %v", op, err)
}
_, err = io.Copy(io.Discard, r)
_, err = io.Copy(ioutil.Discard, r)
if err != errUnexpectedEOF {
t.Fatalf("io.Copy() returned %v, want %v", err, errUnexpectedEOF)
}
@ -489,7 +490,7 @@ func TestReadLimit(t *testing.T) {
if op != BinaryMessage || err != nil {
t.Fatalf("2: NextReader() returned %d, %v", op, err)
}
_, err = io.Copy(io.Discard, r)
_, err = io.Copy(ioutil.Discard, r)
if err != ErrReadLimit {
t.Fatalf("io.Copy() returned %v", err)
}

View File

@ -84,7 +84,7 @@ func echoCopyFull(w http.ResponseWriter, r *http.Request) {
}
// echoReadAll echoes messages from the client by reading the entire message
// with io.ReadAll.
// with ioutil.ReadAll.
func echoReadAll(w http.ResponseWriter, r *http.Request, writeMessage, writePrepared bool) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {

View File

@ -7,6 +7,7 @@ package main
import (
"flag"
"html/template"
"io/ioutil"
"log"
"net/http"
"os"
@ -48,7 +49,7 @@ func readFileIfModified(lastMod time.Time) ([]byte, time.Time, error) {
if !fi.ModTime().After(lastMod) {
return nil, lastMod, nil
}
p, err := os.ReadFile(filename)
p, err := ioutil.ReadFile(filename)
if err != nil {
return nil, fi.ModTime(), err
}

6
go.mod
View File

@ -1,7 +1,3 @@
module github.com/gorilla/websocket
go 1.20
retract (
v1.5.2 // tag accidentally overwritten
)
go 1.12