From 146412ce334ae0468f23b9e747da1e1e13f9584d Mon Sep 17 00:00:00 2001 From: hoelee Date: Tue, 16 Jun 2026 08:08:00 +0800 Subject: [PATCH] feat(botfilter): add statusRecorder.ReadFrom --- botfilter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/botfilter.go b/botfilter.go index 579ca508..7bb5d337 100644 --- a/botfilter.go +++ b/botfilter.go @@ -154,3 +154,12 @@ func (r *statusRecorder) Push(target string, options *http.PushOptions) error { return pusher.Push(target, options) } +func (r *statusRecorder) ReadFrom(source io.Reader) (int64, error) { + if r.status == 0 { + r.status = http.StatusOK + } + if readerFrom, ok := r.ResponseWriter.(io.ReaderFrom); ok { + return readerFrom.ReadFrom(source) + } + return io.Copy(struct{ io.Writer }{Writer: r.ResponseWriter}, source) +}