恢复无 cookie 拉流修复:iPhone 原生播放器(AVPlayer/夸克系统解码)不携带 cookie 时媒体资产可凭会话 ID 拉流,纯 HTTP 生效;新增拉流拒绝诊断日志

This commit is contained in:
yvan
2026-09-18 12:09:28 +08:00
parent 53c87872fc
commit f2802dcc5f
4 changed files with 37 additions and 2 deletions
+12
View File
@@ -207,6 +207,12 @@ func viewerOwnsPlayback(ctx context.Context, session *playbackSession) bool {
return viewer != nil && session != nil && session.viewer == viewer && playbackSourceAllowed(ctx, session)
}
// playbackCapabilityPath 判断是否为无需 viewer cookie 的媒体资产路径:
// 这些 URL 中已包含不可猜测的播放会话 ID,可作为独立能力凭证。
func playbackCapabilityPath(path string) bool {
return strings.HasPrefix(path, "/api/ui/playback/media/") || path == "/api/ui/playback/hls/index.m3u8" || path == "/api/ui/playback/hls/segment.ts"
}
func writeViewerError(writer http.ResponseWriter, status int, code, message string) {
writer.Header().Set("Cache-Control", "private, no-store")
writer.Header().Add("Vary", "Cookie")
@@ -234,6 +240,12 @@ func (app *UIApp) withBrowserViewer(next http.Handler) http.Handler {
}
identity := manager.identity(request)
if account.ID == "" && (identity == "" || accountCookie) {
if playbackCapabilityPath(path) {
// AVPlayer 等原生媒体管线可能不携带 cookie;播放会话 ID 本身即能力凭证,
// 由媒体资产接口自行校验会话与运行编号。
next.ServeHTTP(writer, request)
return
}
writeViewerError(writer, http.StatusUnauthorized, "viewer_required", "请刷新页面,恢复此浏览器的独立观看记录")
return
}