设置Expires Header
(expiresAt int64)
| 655 | |
| 656 | // 设置Expires Header |
| 657 | func (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 | // 尝试读取区间缓存 |
| 675 | func (this *HTTPRequest) tryPartialReader(storage caches.StorageInterface, key string, useStale bool, rangeHeader string, forcePartialContent bool) (resultReader caches.Reader, ranges []rangeutils.Range, goNext bool) { |
no test coverage detected