gin/render
Alex 50c29053dd Fix concurrent write bug in reader.Render
If a caller passed in a map retained within the callers context as
extraHeaders to gin.Context.DataFromReader() then a race to write the
"Content-Lenght" header would occur.

// globalHeader is passed to gin.Context.DataFromReader
var globalHeaders = map[string]string{
    "cache-control": "public, max-age=3600",
}

func (c *gin.Context) {
    //...

    // DataFromReader must not write to globalHeaders
    c.DataFromReader(code, contentLength, contentType, reader,
	globalHeaders)
}
2023-04-12 14:24:37 +02:00
..