X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=fetch.go;h=16e8d902a1d3f179e35a07851650243c61c17abf;hb=c43a74c01d838cef9dfe4aadbff54c03df8f1f1d;hp=ba1bbc8f4bde2019503102a1100ea1cf01bcc0a0;hpb=526f6f1db39bde8ca1f7684225a3983634bddafe;p=nsscash%2Fnsscash.git diff --git a/fetch.go b/fetch.go index ba1bbc8..16e8d90 100644 --- a/fetch.go +++ b/fetch.go @@ -36,14 +36,17 @@ func init() { clients[""] = &http.Client{} } -func fetchIfModified(url, ca string, lastModified *time.Time) (int, []byte, error) { +func fetchIfModified(url, user, pass, ca string, lastModified *time.Time) (int, []byte, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { return 0, nil, err } + if user != "" || pass != "" { + req.SetBasicAuth(user, pass) + } if !lastModified.IsZero() { req.Header.Add("If-Modified-Since", - lastModified.Format(http.TimeFormat)) + lastModified.UTC().Format(http.TimeFormat)) } client, ok := clients[ca]