mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-05 05:27:31 +00:00
chore: save etag in bbolt by msgpack
This commit is contained in:
@@ -117,14 +117,14 @@ func (h *HTTPVehicle) Read(ctx context.Context, oldHash utils.HashType) (buf []b
|
||||
header := h.header
|
||||
setIfNoneMatch := false
|
||||
if etag && oldHash.IsValid() {
|
||||
hashBytes, etag := cachefile.Cache().GetETagWithHash(h.url)
|
||||
if oldHash.Equal(hashBytes) && etag != "" {
|
||||
etagWithHash := cachefile.Cache().GetETagWithHash(h.url)
|
||||
if oldHash.Equal(etagWithHash.Hash) && etagWithHash.ETag != "" {
|
||||
if header == nil {
|
||||
header = http.Header{}
|
||||
} else {
|
||||
header = header.Clone()
|
||||
}
|
||||
header.Set("If-None-Match", etag)
|
||||
header.Set("If-None-Match", etagWithHash.ETag)
|
||||
setIfNoneMatch = true
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,11 @@ func (h *HTTPVehicle) Read(ctx context.Context, oldHash utils.HashType) (buf []b
|
||||
}
|
||||
hash = utils.MakeHash(buf)
|
||||
if etag {
|
||||
cachefile.Cache().SetETagWithHash(h.url, hash, resp.Header.Get("ETag"))
|
||||
cachefile.Cache().SetETagWithHash(h.url, cachefile.EtagWithHash{
|
||||
Hash: hash,
|
||||
ETag: resp.Header.Get("ETag"),
|
||||
Time: time.Now(),
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user