Skip to content

Commit

Permalink
docs: add explaination for the limit check
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaranski authored and keliramu committed Dec 13, 2024
1 parent 72ad505 commit df8d4a0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ func MaxBytesReadAll(r io.Reader) ([]byte, error) {
if err != nil {
return nil, err
}
// check whether the io.ReadAll() stopped because of EOF coming from io.Reader or because of the limit
//
// two cases can happen here:
// limit reached - limitedReader.N <= 0
// io.Reader is empty - limitedReader.N > 0
if limitedReader.N <= 0 {
return nil, &ErrMaxBytesLimit{Limit: maxBytesLimit}
}
Expand Down

0 comments on commit df8d4a0

Please sign in to comment.