all repos — searchix @ cee12761d4ab83d717452e22a34708161f722b1f

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

fix: don't try to parse an empty last-modified header

Alan Pearce
commit

cee12761d4ab83d717452e22a34708161f722b1f

parent

bdb5a54c661407c39668096074a1f4a57898eb77

1 file changed, 11 insertions(+), 9 deletions(-)

changed files
M internal/fetcher/http/http.gointernal/fetcher/http/http.go
@@ -95,20 +95,22 @@ )
} var body io.ReadCloser - var newMtime time.Time + newMtime := time.Now() encoding := res.Header.Get("Content-Encoding") switch res.StatusCode { case http.StatusNotModified: case http.StatusOK: var baseErr error - newMtime, baseErr = time.Parse(time.RFC1123, res.Header.Get("Last-Modified")) - if baseErr != nil { - h.logger.Warn( - "could not parse Last-Modified header from response", - "value", - res.Header.Get("Last-Modified"), - ) - newMtime = time.Now() + if lastMod := res.Header.Get("Last-Modified"); lastMod != "" { + newMtime, baseErr = time.Parse(time.RFC1123, lastMod) + if baseErr != nil { + h.logger.Warn( + "could not parse Last-Modified header from response", + "value", + res.Header.Get("Last-Modified"), + ) + newMtime = time.Now() + } } switch encoding {