mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-27 04:46:35 +08:00
实现gzip
This commit is contained in:
@@ -1,43 +1,9 @@
|
||||
package serverconfigs
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGzipConfig_MatchContentType(t *testing.T) {
|
||||
a := assert.NewAssertion(t)
|
||||
|
||||
{
|
||||
gzip := &HTTPGzipConfig{}
|
||||
a.IsNil(gzip.Init())
|
||||
a.IsTrue(gzip.MatchContentType("text/html"))
|
||||
}
|
||||
|
||||
{
|
||||
gzip := &HTTPGzipConfig{}
|
||||
a.IsNil(gzip.Init())
|
||||
a.IsTrue(gzip.MatchContentType("text/html; charset=utf-8"))
|
||||
}
|
||||
|
||||
{
|
||||
gzip := &HTTPGzipConfig{}
|
||||
gzip.MimeTypes = []string{"text/*"}
|
||||
a.IsNil(gzip.Init())
|
||||
a.IsTrue(gzip.MatchContentType("text/html; charset=utf-8"))
|
||||
}
|
||||
|
||||
{
|
||||
gzip := &HTTPGzipConfig{}
|
||||
gzip.MimeTypes = []string{"text/*"}
|
||||
a.IsNil(gzip.Init())
|
||||
a.IsFalse(gzip.MatchContentType("application/json; charset=utf-8"))
|
||||
}
|
||||
|
||||
{
|
||||
gzip := &HTTPGzipConfig{}
|
||||
gzip.MimeTypes = []string{"text/*", "image/*"}
|
||||
a.IsNil(gzip.Init())
|
||||
a.IsTrue(gzip.MatchContentType("image/jpeg; charset=utf-8"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user