mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-21 20:18:47 +08:00
feat(cloudreve): add custom user-agent (close #5020)
This commit is contained in:
parent
3b74f8cd9a
commit
3bbae29f93
@ -13,6 +13,7 @@ type Addition struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Cookie string `json:"cookie"`
|
||||
CustomUA string `json:"custom_ua"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
@ -22,15 +22,18 @@ const loginPath = "/user/session"
|
||||
|
||||
func (d *Cloudreve) request(method string, path string, callback base.ReqCallback, out interface{}) error {
|
||||
u := d.Address + "/api/v3" + path
|
||||
ua := d.CustomUA
|
||||
if ua == "" {
|
||||
ua = base.UserAgent
|
||||
}
|
||||
req := base.RestyClient.R()
|
||||
req.SetHeaders(map[string]string{
|
||||
"Cookie": "cloudreve-session=" + d.Cookie,
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
|
||||
"User-Agent": ua,
|
||||
})
|
||||
|
||||
var r Resp
|
||||
|
||||
req.SetResult(&r)
|
||||
|
||||
if callback != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user