good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 26dd4ac8 authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Consider StatusGoingAway a io.EOF in NetConn

parent 20ccbc4c
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,8 @@ import ( ...@@ -33,7 +33,8 @@ import (
// The Addr methods will return a mock net.Addr that returns "websocket" for Network // The Addr methods will return a mock net.Addr that returns "websocket" for Network
// and "websocket/unknown-addr" for String. // and "websocket/unknown-addr" for String.
// //
// A received StatusNormalClosure close frame will be translated to EOF when reading. // A received StatusNormalClosure or StatusGoingAway close frame will be translated to
// io.EOF when reading.
func NetConn(c *Conn, msgType MessageType) net.Conn { func NetConn(c *Conn, msgType MessageType) net.Conn {
nc := &netConn{ nc := &netConn{
c: c, c: c,
...@@ -93,7 +94,7 @@ func (c *netConn) Read(p []byte) (int, error) { ...@@ -93,7 +94,7 @@ func (c *netConn) Read(p []byte) (int, error) {
typ, r, err := c.c.Reader(c.readContext) typ, r, err := c.c.Reader(c.readContext)
if err != nil { if err != nil {
var ce CloseError var ce CloseError
if xerrors.As(err, &ce) && (ce.Code == StatusNormalClosure) { if xerrors.As(err, &ce) && (ce.Code == StatusNormalClosure) || (ce.Code == StatusGoingAway) {
c.eofed = true c.eofed = true
return 0, io.EOF return 0, io.EOF
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment