优化Partial Content内容缓存,现在可以使用“部分文件缓存+部分回源”的方式提供内容

This commit is contained in:
GoEdgeLab
2024-05-07 16:20:22 +08:00
parent c1307e42f3
commit 16370307f0
11 changed files with 219 additions and 16 deletions

View File

@@ -88,6 +88,8 @@ type HTTPWriter struct {
cacheReader caches.Reader
cacheReaderSuffix string
statusSent bool
}
// NewHTTPWriter 包装对象
@@ -844,6 +846,11 @@ func (this *HTTPWriter) SetSentHeaderBytes(sentHeaderBytes int64) {
// WriteHeader 写入状态码
func (this *HTTPWriter) WriteHeader(statusCode int) {
if this.statusSent {
return
}
this.statusSent = true
if this.rawWriter != nil {
this.rawWriter.WriteHeader(statusCode)
}