Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrReadLimitExceeded = errors.New("read limit exceeded")
Functions ¶
This section is empty.
Types ¶
type LimitedReadCloser ¶
type LimitedReadCloser struct { R io.ReadCloser // underlying reader N int64 // max bytes remaining // contains filtered or unexported fields }
LimitedReadCloser wraps an io.ReadCloser in limiting behavior using io.LimitedReader. It allows us to obtain the limit error at the time of close instead of just when writing.
func NewLimitedReadCloser ¶
func NewLimitedReadCloser(r io.ReadCloser, n int64) *LimitedReadCloser
NewLimitedReadCloser returns a new LimitedReadCloser.
func (*LimitedReadCloser) Close ¶
func (l *LimitedReadCloser) Close() (err error)
Close returns an ErrReadLimitExceeded when the wrapped reader exceeds the set limit for number of bytes. This is safe to call more than once but not concurrently.
Click to show internal directories.
Click to hide internal directories.