Implemented connection close request
This commit is contained in:
parent
d91c131394
commit
e787609322
@ -121,6 +121,7 @@ func (s *server) handleConnection(conn net.Conn) {
|
|||||||
ctx = s.contextPool.Get().(*context)
|
ctx = s.contextPool.Get().(*context)
|
||||||
method string
|
method string
|
||||||
url string
|
url string
|
||||||
|
close bool
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.reader.Reset(conn)
|
ctx.reader.Reset(conn)
|
||||||
@ -128,7 +129,7 @@ func (s *server) handleConnection(conn net.Conn) {
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
defer s.contextPool.Put(ctx)
|
defer s.contextPool.Put(ctx)
|
||||||
|
|
||||||
for {
|
for !close {
|
||||||
// Read the HTTP request line
|
// Read the HTTP request line
|
||||||
message, err := ctx.reader.ReadString('\n')
|
message, err := ctx.reader.ReadString('\n')
|
||||||
|
|
||||||
@ -183,6 +184,10 @@ func (s *server) handleConnection(conn net.Conn) {
|
|||||||
Key: key,
|
Key: key,
|
||||||
Value: value,
|
Value: value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if value == "close" && strings.EqualFold(key, "connection") {
|
||||||
|
close = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the request
|
// Handle the request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user