mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
proxy: optimize NewConn, avoid loop
This commit is contained in:
1 parent
40ddd1be3a
commit
6fff126e4b
6 files changed
+14
-13
No files matched your search
@@ -45,17 +45,11 @@ func (s *HTTP) ListenAndServe() {
|
||||
func (s *HTTP) Serve(cc net.Conn) {
|
||||
defer cc.Close()
|
||||
|
||||
var c *proxy.Conn
|
||||
switch cc := cc.(type) {
|
||||
case *proxy.Conn:
|
||||
c = cc
|
||||
case *net.TCPConn:
|
||||
cc.SetKeepAlive(true)
|
||||
c = proxy.NewConn(cc)
|
||||
default:
|
||||
c = proxy.NewConn(cc)
|
||||
if c, ok := cc.(*net.TCPConn); ok {
|
||||
c.SetKeepAlive(true)
|
||||
}
|
||||
|
||||
c := proxy.NewConn(cc)
|
||||
req, err := parseRequest(c.Reader())
|
||||
if err != nil {
|
||||
log.F("[http] can not parse request from %s", c.RemoteAddr())
|
||||
|
||||
Reference in new issue
Block a user