X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=fetch.go;h=16e8d902a1d3f179e35a07851650243c61c17abf;hp=491720a88786d0c363bc612048a6ce0e1f6b98b5;hb=44a325a9bea5f53c6489cecb3691709306a1814c;hpb=0ebeb1b4be72405243eadf39f297a13d6d391020 diff --git a/fetch.go b/fetch.go index 491720a..16e8d90 100644 --- a/fetch.go +++ b/fetch.go @@ -36,11 +36,14 @@ 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.UTC().Format(http.TimeFormat))