aboutsummaryrefslogtreecommitdiff
path: root/nvdmirror/util.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-02-24 00:52:19 -0500
committerPaul Duncan <pabs@pablotron.org>2022-02-24 00:52:19 -0500
commit5fa2cbc1cd4c2ccbdf8897fcf9b5263ab050fbf6 (patch)
tree69405b68c3c183bba4df0a08f9cc0e701441e8b0 /nvdmirror/util.go
parentf09a9126c43d00c31b2e5bc9a4fc812b33e4475c (diff)
downloadcvez-5fa2cbc1cd4c2ccbdf8897fcf9b5263ab050fbf6.tar.bz2
cvez-5fa2cbc1cd4c2ccbdf8897fcf9b5263ab050fbf6.zip
nvdmirror: break Sync() into logical chunks, move into syncContext
Diffstat (limited to 'nvdmirror/util.go')
-rw-r--r--nvdmirror/util.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/nvdmirror/util.go b/nvdmirror/util.go
index 9cf7d3a..d54e41b 100644
--- a/nvdmirror/util.go
+++ b/nvdmirror/util.go
@@ -16,7 +16,7 @@ func getFileSize(path string) (uint64, error) {
}
}
-// log array of strings
+// Log array of strings.
func logArray(key string, strs []string) {
// populate array
a := zerolog.Arr()
@@ -27,3 +27,12 @@ func logArray(key string, strs []string) {
// log array
log.Info().Array(key, a).Send()
}
+
+// Get source URL, etag response header, and last-modified response
+// header from fetchResult and save them in the given cache.
+func saveHeaders(cache Cache, fr fetchResult) error {
+ return cache.Set(fr.src, map[string]string {
+ "if-none-match": fr.headers.Get("etag"),
+ "if-modified-since": fr.headers.Get("last-modified"),
+ })
+}