Get Last-Modified for resources with the given URL
This commit is contained in:
parent
0c9adef5ab
commit
5b72676cff
18
utils.go
18
utils.go
|
@ -5,11 +5,29 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
// Get Last-Modified for resources with the given URL.
|
||||
func checkLastModified(url string) (time.Time, error) {
|
||||
r, err := http.Head(url)
|
||||
if err != nil {
|
||||
return time.Unix(0, 0), err
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
t, err := time.Parse(time.RFC1123, r.Header["Last-Modified"][0])
|
||||
if err != nil {
|
||||
return time.Unix(0, 0), err
|
||||
}
|
||||
|
||||
return t, nil
|
||||
|
||||
}
|
||||
|
||||
func download(url, output string) error {
|
||||
|
||||
r, err := http.Get(url)
|
||||
|
|
Loading…
Reference in New Issue