manage normal close in response to close frame

This commit is contained in:
xdrm-brackets 2018-05-08 11:31:37 +02:00
parent ca3b83abee
commit fff5d068d1
2 changed files with 6 additions and 3 deletions

View File

@ -157,7 +157,9 @@ func clientReader(c *client){
msgErr := msg.check(frag != nil) msgErr := msg.check(frag != nil)
// fmt.Printf("> %.3f us\n", float64(time.Now().UnixNano()-s0)/1e3) // fmt.Printf("> %.3f us\n", float64(time.Now().UnixNano()-s0)/1e3)
if msgErr == ErrInvalidPayload { if msgErr == CloseFrame {
break
} else if msgErr == ErrInvalidPayload {
closeStatus = INVALID_PAYLOAD closeStatus = INVALID_PAYLOAD
break break
} else if msgErr != nil { } else if msgErr != nil {

View File

@ -14,6 +14,7 @@ var ErrInvalidSize = fmt.Errorf("Received invalid payload size")
var ErrInvalidPayload = fmt.Errorf("Received invalid utf8 payload") var ErrInvalidPayload = fmt.Errorf("Received invalid utf8 payload")
var ErrInvalidCloseStatus = fmt.Errorf("Received invalid close status") var ErrInvalidCloseStatus = fmt.Errorf("Received invalid close status")
var ErrInvalidOpCode = fmt.Errorf("Received invalid OpCode") var ErrInvalidOpCode = fmt.Errorf("Received invalid OpCode")
var CloseFrame = fmt.Errorf("Received close Frame")
// Maximum Header Size = Final/OpCode + isMask/Length + Length + Mask // Maximum Header Size = Final/OpCode + isMask/Length + Length + Mask
@ -291,7 +292,7 @@ func (m *Message) check(fragment bool) error{
return ErrInvalidCloseStatus return ErrInvalidCloseStatus
} }
} }
return nil return CloseFrame
case PING: case PING:
return nil return nil