1
0
Fork 0

Get Last-Modified for resources with the given URL

This commit is contained in:
Daniele Tricoli 2015-09-16 17:07:32 +02:00
parent 0c9adef5ab
commit 5b72676cff
1 changed files with 18 additions and 0 deletions

View File

@ -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)