mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 05:00:24 +08:00 
			
		
		
		
	当缓存条件状态码为206时,自动支持区间缓存
This commit is contained in:
		@@ -4,7 +4,7 @@ import (
 | 
			
		||||
	"reflect"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 拷贝同类型struct指针对象中的字段
 | 
			
		||||
// CopyStructObject 拷贝同类型struct指针对象中的字段
 | 
			
		||||
func CopyStructObject(destPtr, sourcePtr interface{}) {
 | 
			
		||||
	value := reflect.ValueOf(destPtr)
 | 
			
		||||
	value2 := reflect.ValueOf(sourcePtr)
 | 
			
		||||
 
 | 
			
		||||
@@ -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