From 8321affbca9a659bbbfb33803fc3c889cc39cf9e Mon Sep 17 00:00:00 2001 From: lihaowei Date: Sat, 15 Aug 2020 12:00:40 +0800 Subject: [PATCH] Fix for issue #2460 --- context.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/context.go b/context.go index 95b1807d..baa8eb31 100644 --- a/context.go +++ b/context.go @@ -102,6 +102,7 @@ func (c *Context) reset() { // Copy returns a copy of the current context that can be safely used outside the request's scope. // This has to be used when the context has to be passed to a goroutine. func (c *Context) Copy() *Context { + c.mu.Lock() cp := Context{ writermem: c.writermem, Request: c.Request, @@ -119,6 +120,7 @@ func (c *Context) Copy() *Context { paramCopy := make([]Param, len(cp.Params)) copy(paramCopy, cp.Params) cp.Params = paramCopy + c.mu.Unlock() return &cp } @@ -957,7 +959,7 @@ func (c *Context) File(filepath string) { http.ServeFile(c.Writer, c.Request, filepath) } -// FileFromFS writes the specified file from http.FileSytem into the body stream in an efficient way. +// FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way. func (c *Context) FileFromFS(filepath string, fs http.FileSystem) { defer func(old string) { c.Request.URL.Path = old