mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 15:00:26 +08:00
Partial Content从源站读取数据时验证本地缓存的Content-MD5是否一致
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
package caches_test
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/caches"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
@@ -167,8 +169,13 @@ func TestPartialRanges_Encode_String(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
r.Ranges = append(r.Ranges, [2]int64{int64(i * 100), int64(i*100 + 100)})
|
||||
}
|
||||
|
||||
var sum = md5.Sum([]byte("123456"))
|
||||
r.ContentMD5 = base64.StdEncoding.EncodeToString(sum[:])
|
||||
|
||||
var before = time.Now()
|
||||
var data = r.String()
|
||||
t.Log(data)
|
||||
t.Log(time.Since(before).Seconds()*1000, "ms")
|
||||
t.Log(len(data))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user