Allenxuxu / gev

🚀Gev is a lightweight, fast non-blocking TCP network library / websocket server based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
MIT License
1.72k stars 193 forks source link

存在err被覆盖导致无法触发的bug #85

Closed cs-charles closed 3 years ago

cs-charles commented 3 years ago

https://github.com/Allenxuxu/gev/blob/631f7252a9ca88315d327ed4a26d0f97947abdad/plugins/websocket/ws/ws.go#L305 由于在遍历请求头时,触发对请求头Connection校验的错误,之后触发onHost或者onHeader方法,但是由于onHost或者onHeader方法返回nil,导致原本err=ErrHandshakeBadConnection被nil覆盖。建议用临时变量接收onHost和onHeader返回的错误,只有错误不为空才赋值给err变量。 if onHost := u.OnHost; onHost != nil { if e := onHost(c, v);e != nil; { err = e } }

if onHeader := u.OnHeader; onHeader != nil { if e := onHeader(c, k, v);e != nil { err = e } }

Allenxuxu commented 3 years ago

https://github.com/Allenxuxu/gev/pull/88