支持ZSTD压缩

This commit is contained in:
刘祥超
2022-06-27 22:41:11 +08:00
parent 551cb2f3c1
commit 62027e95b2
2 changed files with 8 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ type HTTPCompressionConfig struct {
supportGzip bool
supportDeflate bool
supportBrotli bool
supportZSTD bool
}
// Init 初始化
@@ -133,6 +134,8 @@ func (this *HTTPCompressionConfig) Init() error {
if this.BrotliRef == nil || (this.BrotliRef != nil && this.BrotliRef.IsOn && this.Brotli != nil && this.Brotli.IsOn) {
this.supportBrotli = true
}
case HTTPCompressionTypeZSTD:
this.supportZSTD = true
}
}
@@ -244,6 +247,10 @@ func (this *HTTPCompressionConfig) MatchAcceptEncoding(acceptEncodings string) (
if this.supportBrotli && lists.ContainsString(encodings, "br") {
return HTTPCompressionTypeBrotli, "br", true
}
case HTTPCompressionTypeZSTD:
if this.supportZSTD && lists.ContainsString(encodings, "zstd") {
return HTTPCompressionTypeZSTD, "zstd", true
}
}
}

View File

@@ -8,4 +8,5 @@ const (
HTTPCompressionTypeGzip HTTPCompressionType = "gzip"
HTTPCompressionTypeDeflate HTTPCompressionType = "deflate"
HTTPCompressionTypeBrotli HTTPCompressionType = "brotli"
HTTPCompressionTypeZSTD HTTPCompressionType = "zstd"
)