缓存写入结束时检查Content-Length是否和实际内容长度一致

This commit is contained in:
GoEdgeLab
2024-04-05 11:45:18 +08:00
parent 1377f25fa4
commit 2213934795
3 changed files with 24 additions and 9 deletions

View File

@@ -136,6 +136,13 @@ func (this *FileWriter) Close() error {
var path = this.rawWriter.Name()
// check content length
if this.metaBodySize > 0 && this.bodySize != this.metaBodySize {
_ = this.rawWriter.Close()
_ = os.Remove(path)
return ErrUnexpectedContentLength
}
err := this.WriteHeaderLength(types.Int(this.headerSize))
if err != nil {
fsutils.WriteBegin()