Skip to content

Commit 4aed38e

Browse files
committed
Set a cap on the content bufffer to prevent frivolous resizing
1 parent aedc95f commit 4aed38e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func (s *Server) logRequest(ctx Context, sTime time.Time) {
328328
func (s *Server) routeHandler(req *http.Request, w http.ResponseWriter) (unused *route) {
329329
routeHit := false
330330
requestPath := req.URL.Path
331-
allContent := make([][]byte, 0)
331+
allContent := make([][]byte, 0, 2)
332332
ctx := Context{req, map[string]string{}, s, w, false}
333333

334334
finishResponse := func() {
@@ -364,8 +364,8 @@ func (s *Server) routeHandler(req *http.Request, w http.ResponseWriter) (unused
364364
}
365365
}
366366

367-
defer s.logRequest(ctx, tm)
368367
defer finishResponse()
368+
defer s.logRequest(ctx, tm)
369369

370370
ctx.SetHeader("Date", webTime(tm), true)
371371

0 commit comments

Comments
 (0)