WAF和其他请求关闭连接时更加快速

This commit is contained in:
GoEdgeLab
2022-08-27 10:49:16 +08:00
parent 328ae09ce7
commit e413adb1b0
3 changed files with 28 additions and 15 deletions

View File

@@ -1428,11 +1428,16 @@ func (this *HTTPRequest) Done() {
func (this *HTTPRequest) Close() {
this.Done()
requestConn := this.RawReq.Context().Value(HTTPConnContextKey)
var requestConn = this.RawReq.Context().Value(HTTPConnContextKey)
if requestConn == nil {
return
}
lingerConn, ok := requestConn.(LingerConn)
if ok {
_ = lingerConn.SetLinger(0)
}
conn, ok := requestConn.(net.Conn)
if ok {
_ = conn.Close()