Skip to content

fix(115): restore Cookie on download link so proxied downloads work (#9452)#9554

Open
okatu-loli wants to merge 1 commit into
mainfrom
fix/115-webdav-download-403
Open

fix(115): restore Cookie on download link so proxied downloads work (#9452)#9554
okatu-loli wants to merge 1 commit into
mainfrom
fix/115-webdav-download-403

Conversation

@okatu-loli

Copy link
Copy Markdown
Collaborator

Fixes #9452

现象

群晖 Cloud Sync 经 WebDAV 下载 115 文件失败;115 CDN(cdnfhnfile.115cdn.net)返回 403 {"message":"no cookie value"}。3.57.0 正常,3.58.0+ 复现(回归)。

根因

3.58.0 的 115 驱动/SDK 重构后,Link 直接用 SDK 的 downloadInfo.Header 作为 model.Link.Header,而该 Header 取自 resty 的请求头 map(download.goinfo.Header = resp.Request.Header)。115 账号 Cookie 是 resty 在传输层注入的,不在这个 Header map 里,于是 link.Header 丢了 Cookie

115 CDN 要求带 Cookie,所以 AList 代理下载时用 link.Header 拼上游请求会得到 403 no cookie value;这正是 issue 中「本地代理模式 AList 后台报 403」的来源。3.57.0 的驱动在本地 DownloadWithUA显式 req.Header.Set("Cookie", d.Cookie),所以没有这个问题。

修复

Link 返回前,若 link.Header 缺少 Cookie,用账号 d.Cookie 补上(幂等、不覆盖 SDK 已有值)。这样代理下载会带上 Cookie + 原有 UA,不再 403。

说明(群晖等 WebDAV 客户端)

115 下载链接绑定 Cookie(还绑 UA/IP),302 重定向无法把 Cookie 传给客户端,因此 115 经 WebDAV 下载需使用代理模式(存储/WebDAV 设为本地代理)。本 PR 修复的正是代理模式此前也失效的问题;302 直链对 115 本质上不可行。未强制 OnlyProxy,以免增加服务器带宽负担。

测试

go build ./drivers/115/go vet ./drivers/115/ 通过。

… work

Since the 3.58.0 driver/SDK refactor, Link builds model.Link.Header from the
SDK's downloadInfo.Header (= the resty request header). The 115 account cookie
is injected by resty at the transport layer, so it is absent from that header.
The 115 CDN requires the cookie, so proxied downloads fail with
403 "no cookie value" — a regression from 3.57.0, where the driver set the
Cookie header explicitly. Restore the Cookie on the link header when missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

群晖使用ALIST挂载115,无法复制文件到NAS本地盘,之前版本正常。

1 participant