mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-19 17:10:24 +08:00
当缓存条件状态码为206时,自动支持区间缓存
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 拷贝同类型struct指针对象中的字段
|
// CopyStructObject 拷贝同类型struct指针对象中的字段
|
||||||
func CopyStructObject(destPtr, sourcePtr interface{}) {
|
func CopyStructObject(destPtr, sourcePtr interface{}) {
|
||||||
value := reflect.ValueOf(destPtr)
|
value := reflect.ValueOf(destPtr)
|
||||||
value2 := reflect.ValueOf(sourcePtr)
|
value2 := reflect.ValueOf(sourcePtr)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ type HTTPCacheRef struct {
|
|||||||
uppercaseSkipCacheControlValues []string
|
uppercaseSkipCacheControlValues []string
|
||||||
|
|
||||||
methodMap map[string]bool
|
methodMap map[string]bool
|
||||||
|
statusList []int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *HTTPCacheRef) Init() error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,3 +128,17 @@ func (this *HTTPCacheRef) MatchRequest(req *http.Request) bool {
|
|||||||
|
|
||||||
return true
|
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