all repos — searchix @ abf819db104560670cdc388a584d09968aac7bbb

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: buffer fetched HTTP bodies
Alan Pearce alan@alanpearce.eu
Mon, 24 Mar 2025 18:37:49 +0100
commit

abf819db104560670cdc388a584d09968aac7bbb

parent

efaaf3f5296807eec377b19d4733fd360c8c655f

2 files changed, 25 insertions(+), 1 deletions(-)

jump to
A internal/fetcher/buf.go
@@ -0,0 +1,24 @@+package fetcher
+
+import (
+	"bufio"
+	"io"
+
+	"gitlab.com/tozd/go/errors"
+)
+
+type Reader struct {
+	closer io.ReadCloser
+	*bufio.Reader
+}
+
+func NewReadCloser(body io.ReadCloser) *Reader {
+	return &Reader{
+		closer: body,
+		Reader: bufio.NewReader(body),
+	}
+}
+
+func (r *Reader) Close() error {
+	return errors.WithStack(r.closer.Close())
+}
M internal/fetcher/http.gointernal/fetcher/http.go
@@ -94,5 +94,5 @@ default: 		err = errors.Errorf("got response code %d, don't know what to do", res.StatusCode)
 	}
 
-	return body, newMtime, err
+	return NewReadCloser(body), newMtime, err
 }