* fix(mopan):302 Redirect * fix(mopan): do not forget to close the body --------- Co-authored-by: Andy Hsu <i@nn.ci>
This commit is contained in:
parent
91f51f17d0
commit
55a14bc271
@ -119,10 +119,13 @@ func (d *MoPan) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.DownloadUrl = strings.Replace(strings.ReplaceAll(data.DownloadUrl, "&", "&"), "http://", "https://", 1)
|
data.DownloadUrl = strings.Replace(strings.ReplaceAll(data.DownloadUrl, "&", "&"), "http://", "https://", 1)
|
||||||
res, err := base.NoRedirectClient.R().SetContext(ctx).Head(data.DownloadUrl)
|
res, err := base.NoRedirectClient.R().SetDoNotParseResponse(true).SetContext(ctx).Get(data.DownloadUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
_ = res.RawBody().Close()
|
||||||
|
}()
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
data.DownloadUrl = res.Header().Get("location")
|
data.DownloadUrl = res.Header().Get("location")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user