Implemented connection close request
This commit is contained in:
parent
b3271e03b7
commit
d58f68f3fe
1 changed files with 6 additions and 1 deletions
|
@ -121,6 +121,7 @@ func (s *server) handleConnection(conn net.Conn) {
|
|||
ctx = s.contextPool.Get().(*context)
|
||||
method string
|
||||
url string
|
||||
close bool
|
||||
)
|
||||
|
||||
ctx.reader.Reset(conn)
|
||||
|
@ -128,7 +129,7 @@ func (s *server) handleConnection(conn net.Conn) {
|
|||
defer conn.Close()
|
||||
defer s.contextPool.Put(ctx)
|
||||
|
||||
for {
|
||||
for !close {
|
||||
// Read the HTTP request line
|
||||
message, err := ctx.reader.ReadString('\n')
|
||||
|
||||
|
@ -183,6 +184,10 @@ func (s *server) handleConnection(conn net.Conn) {
|
|||
Key: key,
|
||||
Value: value,
|
||||
})
|
||||
|
||||
if value == "close" && strings.EqualFold(key, "connection") {
|
||||
close = true
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the request
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue