Plugins: share http cache (#18152)

This commit is contained in:
andig 2025-01-09 21:50:39 +01:00 • committed by GitHub
parent 9308876bad
commit ba96fbbc71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,8 @@ func init() {
registry.AddCtx("http", NewHTTPProviderFromConfig)
}
var mc = httpcache.NewMemoryCache()
// Auth is the authorization config
type Auth struct {
Type, User, Password string
@ -101,9 +103,10 @@ func NewHTTP(log *util.Logger, method, uri string, insecure bool, cache time.Dur
}
// http cache
cacheTransport := httpcache.NewMemoryCacheTransport()
cacheTransport.Transport = p.Client.Transport
p.Client.Transport = cacheTransport
p.Client.Transport = &httpcache.Transport{
Cache: mc,
Transport: p.Client.Transport,
}
// ignore the self signed certificate
if insecure {