mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	限制WebP可转换的最大长度为128M(非ChunkEncoding下)
This commit is contained in:
		@@ -12,6 +12,7 @@ import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils/readers"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils/sizes"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils/writers"
 | 
			
		||||
	_ "github.com/biessek/golang-ico"
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
@@ -448,6 +449,16 @@ func (this *HTTPWriter) PrepareWebP(resp *http.Response, size int64) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 限制最小和最大尺寸
 | 
			
		||||
	// TODO 需要可以在集群里WebP选项里设置
 | 
			
		||||
	// TODO 需要将reader修改为LimitReader
 | 
			
		||||
	if resp.ContentLength == 0 {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if resp.ContentLength > 128*sizes.M {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var contentType = this.GetHeader("Content-Type")
 | 
			
		||||
 | 
			
		||||
	if this.req.web != nil &&
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user