MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / addExpiresHeader

Method addExpiresHeader

internal/nodes/http_request_cache.go:657–672  ·  view source on GitHub ↗

设置Expires Header

(expiresAt int64)

Source from the content-addressed store, hash-verified

655
656// 设置Expires Header
657func (this *HTTPRequest) addExpiresHeader(expiresAt int64) {
658 if this.cacheRef.ExpiresTime != nil && this.cacheRef.ExpiresTime.IsPrior && this.cacheRef.ExpiresTime.IsOn {
659 if this.cacheRef.ExpiresTime.Overwrite || len(this.writer.Header().Get("Expires")) == 0 {
660 if this.cacheRef.ExpiresTime.AutoCalculate {
661 this.writer.Header().Set("Expires", time.Unix(utils.GMTUnixTime(expiresAt), 0).Format("Mon, 2 Jan 2006 15:04:05")+" GMT")
662 this.writer.Header().Del("Cache-Control")
663 } else if this.cacheRef.ExpiresTime.Duration != nil {
664 var duration = this.cacheRef.ExpiresTime.Duration.Duration()
665 if duration > 0 {
666 this.writer.Header().Set("Expires", utils.GMTTime(time.Now().Add(duration)).Format("Mon, 2 Jan 2006 15:04:05")+" GMT")
667 this.writer.Header().Del("Cache-Control")
668 }
669 }
670 }
671 }
672}
673
674// 尝试读取区间缓存
675func (this *HTTPRequest) tryPartialReader(storage caches.StorageInterface, key string, useStale bool, rangeHeader string, forcePartialContent bool) (resultReader caches.Reader, ranges []rangeutils.Range, goNext bool) {

Callers 1

doCacheReadMethod · 0.95

Calls 8

GMTUnixTimeFunction · 0.92
GMTTimeFunction · 0.92
UnixMethod · 0.80
FormatMethod · 0.65
AddMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected