fix(115): restore Cookie on download link so proxied downloads work (#9452)#9554
Open
okatu-loli wants to merge 1 commit into
Open
fix(115): restore Cookie on download link so proxied downloads work (#9452)#9554okatu-loli wants to merge 1 commit into
okatu-loli wants to merge 1 commit into
Conversation
… 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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.go里info.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/通过。