mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-05-02 04:45:17 +08:00
当缓存条件状态码为206时,自动支持区间缓存
This commit is contained in:
@@ -38,7 +38,8 @@ type HTTPCacheRef struct {
|
||||
maxSize int64
|
||||
uppercaseSkipCacheControlValues []string
|
||||
|
||||
methodMap map[string]bool
|
||||
methodMap map[string]bool
|
||||
statusList []int
|
||||
}
|
||||
|
||||
func (this *HTTPCacheRef) Init() error {
|
||||
@@ -82,6 +83,16 @@ func (this *HTTPCacheRef) Init() error {
|
||||
}
|
||||
}
|
||||
|
||||
// status
|
||||
this.statusList = this.Status
|
||||
if this.AllowPartialContent {
|
||||
if !lists.ContainsInt(this.statusList, http.StatusPartialContent) {
|
||||
this.statusList = append(this.statusList, http.StatusPartialContent)
|
||||
}
|
||||
} else if lists.ContainsInt(this.statusList, http.StatusPartialContent) {
|
||||
this.AllowPartialContent = true
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -117,3 +128,17 @@ func (this *HTTPCacheRef) MatchRequest(req *http.Request) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// MatchStatus 检查是否包含某个状态码
|
||||
func (this *HTTPCacheRef) MatchStatus(statusCode int) bool {
|
||||
if len(this.statusList) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, status := range this.statusList {
|
||||
if status == statusCode {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user