mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-27 01:50:30 +08:00
Partial Content从源站读取数据时验证本地缓存的Content-MD5是否一致
This commit is contained in:
@@ -42,8 +42,25 @@ func (this *HTTPRequestPartialReader) Read(p []byte) (n int, err error) {
|
||||
err = io.ErrUnexpectedEOF
|
||||
return
|
||||
}
|
||||
|
||||
this.resp = resp
|
||||
|
||||
// 对比Content-MD5
|
||||
partialReader, ok := this.cacheReader.(*caches.PartialFileReader)
|
||||
if ok {
|
||||
if partialReader.Ranges().Version >= 2 && resp.Header.Get("Content-MD5") != partialReader.Ranges().ContentMD5 {
|
||||
err = io.ErrUnexpectedEOF
|
||||
|
||||
var storage = this.req.writer.cacheStorage
|
||||
if storage != nil {
|
||||
_ = storage.Delete(this.req.cacheKey + caches.SuffixPartial)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 准备写入
|
||||
this.prepareCacheWriter()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user