缓存设置中增加“支持分片内容”选项,用来支持Chunked内容

This commit is contained in:
GoEdgeLab
2021-04-18 22:17:17 +08:00
parent f40ab2c1e2
commit e977d25e27

View File

@@ -304,7 +304,7 @@ func (this *HTTPWriter) prepareGzip(size int64) {
// 准备缓存 // 准备缓存
func (this *HTTPWriter) prepareCache(size int64) { func (this *HTTPWriter) prepareCache(size int64) {
if this.writer == nil || size <= 0 { if this.writer == nil {
return return
} }
@@ -319,10 +319,16 @@ func (this *HTTPWriter) prepareCache(size int64) {
} }
cacheRef := this.req.cacheRef cacheRef := this.req.cacheRef
if cacheRef == nil || if cacheRef == nil || !cacheRef.IsOn {
!cacheRef.IsOn || return
(cacheRef.MaxSizeBytes() > 0 && size > cacheRef.MaxSizeBytes()) || }
(cachePolicy.MaxSizeBytes() > 0 && size > cachePolicy.MaxSizeBytes()) {
// 如果允许 ChunkedEncoding就无需尺寸的判断因为此时的 size 为 -1
if !cacheRef.AllowChunkedEncoding && size < 0 {
return
}
if size >= 0 && ((cacheRef.MaxSizeBytes() > 0 && size > cacheRef.MaxSizeBytes()) ||
(cachePolicy.MaxSizeBytes() > 0 && size > cachePolicy.MaxSizeBytes())) {
return return
} }