mirror of https://github.com/Xhofe/alist
🐛 fix 123pan webdav can't get
parent
d955038ebc
commit
4ff2756572
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
url "net/url"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
@ -149,6 +150,19 @@ func (driver Pan123) Link(path string, account *model.Account) (string, error) {
|
|||
}
|
||||
return "", fmt.Errorf(resp.Message)
|
||||
}
|
||||
u,err := url.Parse(resp.Data.DownloadUrl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
u_ := fmt.Sprintf("https://%s%s",u.Host,u.Path)
|
||||
res, err := drivers.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Get(u_)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Debug(res.String())
|
||||
if res.StatusCode() == 302 {
|
||||
return res.Header().Get("location"), nil
|
||||
}
|
||||
return resp.Data.DownloadUrl, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -69,4 +69,5 @@ func init() {
|
|||
return http.ErrUseLastResponse
|
||||
}),
|
||||
)
|
||||
NoRedirectClient.SetHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue