From 21c80aea784a6be6cbde1234d568323edf8dd660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 4 Mar 2022 17:09:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E6=94=AF=E6=8C=81=E5=AF=B9GET?= =?UTF-8?q?=E4=BB=A5=E5=A4=96=E7=9A=84=E6=96=B9=E6=B3=95=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84Partial=E5=86=85=E5=AE=B9=E7=9A=84=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_writer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/nodes/http_writer.go b/internal/nodes/http_writer.go index 007fe68..9f038e9 100644 --- a/internal/nodes/http_writer.go +++ b/internal/nodes/http_writer.go @@ -101,7 +101,12 @@ func (this *HTTPWriter) Prepare(resp *http.Response, size int64, status int, ena this.statusCode = status // 是否为区间请求 - this.isPartial = status == http.StatusPartialContent && this.req.Method() != http.MethodHead + this.isPartial = status == http.StatusPartialContent + + // 不支持对GET以外的方法返回的Partial内容的缓存 + if this.isPartial && this.req.Method() != http.MethodGet { + enableCache = false + } if resp != nil && resp.Body != nil { cacheReader, ok := resp.Body.(caches.Reader)