From e5f1f42259b9bbf905f3dbd871c0a694d427de76 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 7 May 2024 16:32:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E7=9A=84Partial=20Content=20Range=E8=8C=83=E5=9B=B4=E5=A4=9A1?= =?UTF-8?q?=E5=AD=97=E8=8A=82=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_cache.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/nodes/http_request_cache.go b/internal/nodes/http_request_cache.go index 6920d85..4f8016c 100644 --- a/internal/nodes/http_request_cache.go +++ b/internal/nodes/http_request_cache.go @@ -530,6 +530,7 @@ func (this *HTTPRequest) doCacheRead(useStale bool) (shouldStop bool) { if firstRangeEnd > 0 { rangeEnd = firstRangeEnd } + err = reader.ReadBodyRange(bodyBuf.Bytes, ranges[0].Start(), rangeEnd, func(n int) (goNext bool, readErr error) { _, readErr = this.writer.Write(bodyBuf.Bytes[:n]) if readErr != nil { @@ -725,7 +726,7 @@ func (this *HTTPRequest) tryPartialReader(storage caches.StorageInterface, key s r2, findOk := partialReader.Ranges().FindRangeAtPosition(r.Start()) if findOk && r2.Length() >= (256<<10) /* worth reading */ { isOk = true - ranges[0] = [2]int64{r.Start(), partialReader.BodySize()} // Content-Range: bytes 0-[CONTENT_LENGTH - 1]/CONTENT_LENGTH + ranges[0] = [2]int64{r.Start(), partialReader.BodySize() - 1} // Content-Range: bytes 0-[CONTENT_LENGTH - 1]/CONTENT_LENGTH pReader.SetNextReader(NewHTTPRequestPartialReader(this, r2.End(), partialReader)) return pReader, ranges, r2.End() - 1 /* not include last byte */, true