add support for http.ConnState

issue #205
This commit is contained in:
徐乔伦
2018-08-30 16:17:40 +08:00
committed by Kirill Danshin
parent 373357d2d4
commit 69613e6feb
2 changed files with 27 additions and 1 deletions
+7 -1
View File
@@ -2,6 +2,7 @@ package fasthttp
import (
"net"
"net/http"
"runtime"
"strings"
"sync"
@@ -35,6 +36,8 @@ type workerPool struct {
stopCh chan struct{}
workerChanPool sync.Pool
connState func(net.Conn, http.ConnState)
}
type workerChan struct {
@@ -216,8 +219,11 @@ func (wp *workerPool) workerFunc(ch *workerChan) {
wp.Logger.Printf("error when serving connection %q<->%q: %s", c.LocalAddr(), c.RemoteAddr(), err)
}
}
if err != errHijacked {
if err == errHijacked {
wp.connState(c, http.StateHijacked)
} else {
c.Close()
wp.connState(c, http.StateClosed)
}
c = nil