This commit is contained in:
hunshcn 2024-05-18 17:49:24 +08:00
parent a595606ccb
commit ffb783ab9c
No known key found for this signature in database
GPG key ID: DFE918655CFF7220

View file

@ -19,13 +19,14 @@ import (
type bodyWrapper struct {
io.ReadCloser
once sync.Once
onHitEOF func()
}
func (b *bodyWrapper) Read(p []byte) (n int, err error) {
n, err = b.ReadCloser.Read(p)
if err == io.EOF && b.onHitEOF != nil {
b.onHitEOF()
b.once.Do(b.onHitEOF)
}
return n, err
}