diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2021-04-26 17:15:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-26 17:15:17 +0800 |
| commit | 4ee58922eff61a5a4ca29c0b4829b097a498549e (patch) | |
| tree | 301805fef4aa5d0096bfb1510536f7a009b661e7 /weed/util/http_util.go | |
| parent | 5cdff56731d6be220d4d6e8624b859520dfeb021 (diff) | |
| parent | 86185262bb86e31f9a2f71e85d02df2502c7ad40 (diff) | |
| download | seaweedfs-4ee58922eff61a5a4ca29c0b4829b097a498549e.tar.xz seaweedfs-4ee58922eff61a5a4ca29c0b4829b097a498549e.zip | |
Merge pull request #6 from chrislusf/master
Diffstat (limited to 'weed/util/http_util.go')
| -rw-r--r-- | weed/util/http_util.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/weed/util/http_util.go b/weed/util/http_util.go index eff282bab..1630760b1 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -124,6 +124,27 @@ func Delete(url string, jwt string) error { return errors.New(string(body)) } +func DeleteProxied(url string, jwt string) (body []byte, httpStatus int, err error) { + req, err := http.NewRequest("DELETE", url, nil) + if jwt != "" { + req.Header.Set("Authorization", "BEARER "+string(jwt)) + } + if err != nil { + return + } + resp, err := client.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + body, err = ioutil.ReadAll(resp.Body) + if err != nil { + return + } + httpStatus = resp.StatusCode + return +} + func GetBufferStream(url string, values url.Values, allocatedBytes []byte, eachBuffer func([]byte)) error { r, err := client.PostForm(url, values) if err != nil { @@ -313,7 +334,7 @@ func ReadUrlAsStream(fileUrl string, cipherKey []byte, isContentGzipped bool, is } func readEncryptedUrl(fileUrl string, cipherKey []byte, isContentCompressed bool, isFullChunk bool, offset int64, size int, fn func(data []byte)) (bool, error) { - encryptedData, retryable, err := FastGet(fileUrl) + encryptedData, retryable, err := Get(fileUrl) if err != nil { return retryable, fmt.Errorf("fetch %s: %v", fileUrl, err) } |
