diff --git a/go_cloud/internal/http/routes.go b/go_cloud/internal/http/routes.go index da4e3ee..68cda69 100644 --- a/go_cloud/internal/http/routes.go +++ b/go_cloud/internal/http/routes.go @@ -4238,12 +4238,15 @@ func uploadUserAvatarHandler(w http.ResponseWriter, r *http.Request, db *databas for i := 0; i < verifyRetries; i++ { vctx, vcancel := context.WithTimeout(r.Context(), time.Duration(verifyTimeout)*time.Second) resp, derr := internalClient.Download(vctx, avatarPath, "") - vcancel() if derr == nil && resp != nil { + // Close body while context is still valid resp.Body.Close() + vcancel() verified = true break } + // Cancel context for failed attempt + vcancel() fmt.Printf("[WARN] avatar verification attempt %d/%d failed for %s: %v\n", i+1, verifyRetries, avatarPath, derr) time.Sleep(time.Duration(300*(1<