Skip to content

Commit

Permalink
minor fixes on documentation. (gobwas#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
navossoc authored and gobwas committed Jun 13, 2019
1 parent 584c339 commit 05baaea
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,16 @@ func main() {
if string(host) == "github.com" {
return nil
}
return &ws.RejectConnectionError(
return ws.RejectConnectionError(
ws.RejectionStatus(403),
ws.RejectionHeader(ws.HandshakeHeaderString(
"X-Want-Host: github.com",
"X-Want-Host: github.com\r\n",
)),
)
},
OnHeader: func(key, value []byte) error {
if string(key) != "Cookie" {
return
return nil
}
ok := httphead.ScanCookie(value, func(key, value []byte) bool {
// Check session here or do some other stuff with cookies.
Expand All @@ -329,12 +329,12 @@ func main() {
if ok {
return nil
}
return &ws.RejectConnectionError(
return ws.RejectConnectionError(
ws.RejectionReason("bad cookie"),
ws.RejectionStatus(400),
)
},
OnBeforeUpgrade: func() (HandshakeHeader, error) {
OnBeforeUpgrade: func() (ws.HandshakeHeader, error) {
return header, nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion dialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func TestDialerHandshake(t *testing.T) {
}
}

// Used to emulate net.Error behaviour, which is usually returned when
// Used to emulate net.Error behavior, which is usually returned when
// connection deadline exceeds.
type errTimeout struct {
error
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type HTTPUpgrader struct {

// Upgrade upgrades http connection to the websocket connection.
//
// It hijacks net.Conn from w and returns recevied net.Conn and
// It hijacks net.Conn from w and returns received net.Conn and
// bufio.ReadWriter. On successful handshake it returns Handshake struct
// describing handshake info.
func (u HTTPUpgrader) Upgrade(r *http.Request, w http.ResponseWriter) (conn net.Conn, rw *bufio.ReadWriter, hs Handshake, err error) {
Expand Down
4 changes: 2 additions & 2 deletions wsutil/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *CipherReader) Read(p []byte) (n int, err error) {
}

// CipherWriter implements io.Writer that applies xor-cipher to the bytes
// written to the destination writer. It does not modifiy the original bytes.
// written to the destination writer. It does not modify the original bytes.
type CipherWriter struct {
w io.Writer
mask [4]byte
Expand All @@ -57,7 +57,7 @@ func (c *CipherWriter) Reset(w io.Writer, mask [4]byte) {
c.pos = 0
}

// Write implements io.Writer interface. It applies mask vien during
// Write implements io.Writer interface. It applies masking during
// initialization to every sent byte. It does not modify original slice.
func (c *CipherWriter) Write(p []byte) (n int, err error) {
cp := pbytes.GetLen(len(p))
Expand Down
4 changes: 2 additions & 2 deletions wsutil/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// Note that it must not be used in production applications that requires
// Dial() to be efficient.
type DebugDialer struct {
// Dialer contains WebSocket connection establishement options.
// Dialer contains WebSocket connection establishment options.
Dialer ws.Dialer

// OnRequest and OnResponse are the callbacks that will be called with the
Expand Down Expand Up @@ -70,7 +70,7 @@ func (d *DebugDialer) Dial(ctx context.Context, urlstr string) (conn net.Conn, b
onRequest(reqBuf.Bytes())
}
if onResponse := d.OnResponse; onResponse != nil {
// We must split response iniside buffered bytes from other received
// We must split response inside buffered bytes from other received
// bytes from server.
p := resBuf.Bytes()
n := bytes.Index(p, headEnd)
Expand Down
2 changes: 1 addition & 1 deletion wsutil/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ControlHandler struct {
// header could not be handled.
var ErrNotControlFrame = errors.New("not a control frame")

// Handle handles control framse regarding to the c.State and writes responses
// Handle handles control frames regarding to the c.State and writes responses
// to the c.Dst when needed.
//
// It returns ErrNotControlFrame when given header is not of ws.OpClose,
Expand Down
2 changes: 1 addition & 1 deletion wsutil/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func ReadMessage(r io.Reader, s ws.State, m []Message) ([]Message, error) {
// No more frames will be read. Use fixed sized buffer to read payload.
p = make([]byte, h.Length)
// It is not possible to receive io.EOF here because Reader does not
// return EOF if frame payload was successfuly fetched.
// return EOF if frame payload was successfully fetched.
// Thus we consistent here with io.Reader behavior.
_, err = io.ReadFull(&rd, p)
} else {
Expand Down
2 changes: 1 addition & 1 deletion wsutil/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *Reader) Read(p []byte) (n int, err error) {
}

// Discard discards current message unread bytes.
// It discards all frames of fragmeneted message.
// It discards all frames of fragmented message.
func (r *Reader) Discard() (err error) {
for {
_, err = io.Copy(ioutil.Discard, &r.raw)
Expand Down
2 changes: 1 addition & 1 deletion wsutil/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type DebugUpgrader struct {
// Upgrade calls Upgrade() on underlying ws.Upgrader and tracks I/O on conn.
func (d *DebugUpgrader) Upgrade(conn io.ReadWriter) (hs ws.Handshake, err error) {
var (
// Take the Reader and Writer partst from conn to be probably replaced
// Take the Reader and Writer parts from conn to be probably replaced
// below.
r io.Reader = conn
w io.Writer = conn
Expand Down
2 changes: 1 addition & 1 deletion wsutil/utf8.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
)

// ErrInvalidUTF8 is returned by UTF8 reader on invalid utf8 sequnce.
// ErrInvalidUTF8 is returned by UTF8 reader on invalid utf8 sequence.
var ErrInvalidUTF8 = fmt.Errorf("invalid utf8")

// UTF8Reader implements io.Reader that calculates utf8 validity state after
Expand Down
4 changes: 2 additions & 2 deletions wsutil/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (w *Writer) Write(p []byte) (n int, err error) {
// this could bring unwanted fragmentation. That is, user could create
// buffer with size that fits exactly all further Write() call, and then
// call Flush(), excepting that single and not fragmented frame will be
// sent. With preemtive flush this case will produce two frames – last one
// sent. With preemptive flush this case will produce two frames – last one
// will be empty and just to set fin = true.

return n, w.err
Expand Down Expand Up @@ -347,7 +347,7 @@ func (w *Writer) ReadFrom(src io.Reader) (n int64, err error) {
n += int64(nn)
}
if err == io.EOF {
// NOTE: Do not flush preemtively.
// NOTE: Do not flush preemptively.
// See the Write() sources for more info.
err = nil
w.dirty = true
Expand Down
2 changes: 1 addition & 1 deletion wsutil/wsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Overview:
// handle err
}
// Preapre to read payload.
// Prepare to read payload.
r := io.LimitReader(conn, header.Length)
r = wsutil.NewCipherReader(r, header.Mask)
r = wsutil.NewUTF8Reader(r)
Expand Down

0 comments on commit 05baaea

Please sign in to comment.