diff options
| author | Konstantin Lebedev <lebedev_k@tochka.com> | 2021-03-15 18:52:59 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <lebedev_k@tochka.com> | 2021-03-15 18:52:59 +0500 |
| commit | 7194a5e7bf38ec136ea8ec8f6b50960d598a4d95 (patch) | |
| tree | 2592df165f200937740f712a09743cda9445028a /weed/util/fasthttp_util.go | |
| parent | 9f00f95bfb8dcf118ade083c66122725f25fdd45 (diff) | |
| download | seaweedfs-7194a5e7bf38ec136ea8ec8f6b50960d598a4d95.tar.xz seaweedfs-7194a5e7bf38ec136ea8ec8f6b50960d598a4d95.zip | |
avoid http error: superfluous response.WriteHeader
https://github.com/chrislusf/seaweedfs/issues/1838
Diffstat (limited to 'weed/util/fasthttp_util.go')
| -rw-r--r-- | weed/util/fasthttp_util.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/weed/util/fasthttp_util.go b/weed/util/fasthttp_util.go index 6c31a40da..02c78e79d 100644 --- a/weed/util/fasthttp_util.go +++ b/weed/util/fasthttp_util.go @@ -72,12 +72,11 @@ func FastGet(url string) ([]byte, bool, error) { return out, false, nil } -func FastReadUrlAsStream(fileUrl string, cipherKey []byte, isContentGzipped bool, isFullChunk bool, offset int64, size int, fn func(data []byte)) (retryable bool, err error) { +func FastReadUrlAsStream(fileUrl string, cipherKey []byte, isContentGzipped bool, isFullChunk bool, isCheck bool, offset int64, size int, fn func(data []byte)) (retryable bool, err error) { if cipherKey != nil { return readEncryptedUrl(fileUrl, cipherKey, isContentGzipped, isFullChunk, offset, size, fn) } - req := fasthttp.AcquireRequest() res := fasthttp.AcquireResponse() defer fasthttp.ReleaseRequest(req) @@ -85,7 +84,9 @@ func FastReadUrlAsStream(fileUrl string, cipherKey []byte, isContentGzipped bool req.SetRequestURIBytes([]byte(fileUrl)) - if isFullChunk { + if isCheck { + req.Header.Add("Range", "bytes=0-1") + } else if isFullChunk { req.Header.Add("Accept-Encoding", "gzip") } else { req.Header.Add("Range", fmt.Sprintf("bytes=%d-%d", offset, offset+int64(size)-1)) |
