usar buffers de 8MB

This commit is contained in:
Cat /dev/Nulo 2023-01-20 11:21:12 -03:00
parent 51b7a806e2
commit fc01157a81

View file

@ -124,7 +124,8 @@ func (r *cache) ServeHTTP(w http.ResponseWriter, req *http.Request) {
http.Error(w, "server error", http.StatusInternalServerError)
return
}
_, err = io.Copy(file, req.Body)
buf := [8 * 1024 * 1024]byte{}
_, err = io.CopyBuffer(file, req.Body, buf[:])
if err != nil {
log.Printf("io.Copy: %w", err)
http.Error(w, "server error", http.StatusInternalServerError)
@ -142,7 +143,8 @@ func (r *cache) ServeHTTP(w http.ResponseWriter, req *http.Request) {
http.Error(w, "server error", http.StatusInternalServerError)
return
}
_, err = io.Copy(w, file)
buf := [8 * 1024 * 1024]byte{}
_, err = io.CopyBuffer(w, file, buf[:])
if err != nil {
log.Printf("io.Copy: %w", err)
http.Error(w, "server error", http.StatusInternalServerError)