1
1
mirror of https://github.com/go-gitea/gitea synced 2025-11-21 21:58:21 +00:00

Limit reading bytes instead of ReadAll (#35928)

This commit is contained in:
wxiaoguang
2025-11-12 19:44:49 +08:00
committed by GitHub
parent 2223be2cc4
commit 372d24b84b
10 changed files with 64 additions and 30 deletions

View File

@@ -29,7 +29,7 @@ func ReadAtMost(r io.Reader, buf []byte) (n int, err error) {
// ReadWithLimit reads at most "limit" bytes from r into buf.
// If EOF or ErrUnexpectedEOF occurs while reading, err will be nil.
func ReadWithLimit(r io.Reader, n int) (buf []byte, err error) {
return readWithLimit(r, 1024, n)
return readWithLimit(r, 4*1024, n)
}
func readWithLimit(r io.Reader, batch, limit int) ([]byte, error) {