improve ghttp.Server by closing the request and response body to release the file descriptor in time

This commit is contained in:
Jack 2020-08-08 11:09:58 +08:00
parent c7f1c881c0
commit 9f79453334

View File

@ -73,6 +73,13 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Close the session, which automatically update the TTL
// of the session if it exists.
request.Session.Close()
// Close the request and response body
// to release the file descriptor in time.
request.Request.Body.Close()
if request.Request.Response != nil {
request.Request.Response.Body.Close()
}
}()
// ============================================================