mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-02 14:00:25 +08:00
Partial Content新创建时不对比Content-MD5
This commit is contained in:
@@ -355,23 +355,28 @@ func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64) {
|
||||
}
|
||||
this.cacheWriter = cacheWriter
|
||||
|
||||
// 对比Content-MD5
|
||||
{
|
||||
if this.isPartial {
|
||||
partialWriter, ok := cacheWriter.(*caches.PartialFileWriter)
|
||||
if ok {
|
||||
if partialWriter.Ranges().Version >= 2 && partialWriter.Ranges().ContentMD5 != this.Header().Get("Content-MD5") {
|
||||
_ = this.cacheWriter.Discard()
|
||||
this.cacheWriter = nil
|
||||
return
|
||||
// 判断是否新创建的缓存文件
|
||||
this.partialFileIsNew = partialWriter.IsNew()
|
||||
|
||||
if this.partialFileIsNew {
|
||||
var contentMD5 = this.rawWriter.Header().Get("Content-MD5")
|
||||
if len(contentMD5) > 0 {
|
||||
partialWriter.SetContentMD5(contentMD5)
|
||||
}
|
||||
} else {
|
||||
// 对比Content-MD5
|
||||
if partialWriter.Ranges().Version >= 2 && partialWriter.Ranges().ContentMD5 != this.Header().Get("Content-MD5") {
|
||||
_ = this.cacheWriter.Discard()
|
||||
this.cacheWriter = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否新创建的缓存文件
|
||||
if this.isPartial {
|
||||
this.partialFileIsNew = cacheWriter.(*caches.PartialFileWriter).IsNew()
|
||||
}
|
||||
|
||||
// 写入Header
|
||||
var headerBuf = utils.SharedBufferPool.Get()
|
||||
for k, v := range this.Header() {
|
||||
@@ -416,11 +421,6 @@ func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64) {
|
||||
return
|
||||
}
|
||||
partialWriter.SetBodyLength(total)
|
||||
|
||||
var contentMD5 = this.rawWriter.Header().Get("Content-MD5")
|
||||
if len(contentMD5) > 0 {
|
||||
partialWriter.SetContentMD5(contentMD5)
|
||||
}
|
||||
}
|
||||
var filterReader = readers.NewFilterReaderCloser(resp.Body)
|
||||
this.cacheIsFinished = true
|
||||
@@ -480,11 +480,6 @@ func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64) {
|
||||
// 写入total
|
||||
if !writtenTotal && total > 0 {
|
||||
partialWriter.SetBodyLength(total)
|
||||
var contentMD5 = this.rawWriter.Header().Get("Content-MD5")
|
||||
if len(contentMD5) > 0 {
|
||||
partialWriter.SetContentMD5(contentMD5)
|
||||
}
|
||||
|
||||
writtenTotal = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user