Repository navigation
feat(engine): replace a live session's request headers without a rebuild (#792) - #793
Conversation
…ild (superuser404notfound#792) updateRequestHeaders(_:) hands the session a new header set and the next request each of its source readers makes carries it. One RequestHeaderStore per load feeds the playback demuxer, the producer's reopens and revives, and the I-frame and embedded-subtitle side readers, which used to freeze a copy of LoadOptions.httpHeaders at their open. A reconnect already backing off over a refused credential sends the new set on its next attempt. The set is also installed into loadedOptions so rebuilds replay it. Routes whose requests are fixed at load (remoteBypass, AVPlayer audio, custom IOReader, remote disc image) report .installedForNextRebuild.
…'s request headers without a rebuild
|
Merged in 4768000, thank you. The tests pass on top of current main (4907), and the three places I flagged hold: the warm-connection check compares against the store through the computed One gap I closed in a follow-up, 83aefbf: Not released yet; it goes out with the next engine release. Part 2 of #792 is next on my side. |
|
Perfect, thanks for the quick turnaround as always! |
Closes part 1 of #792.
What
updateRequestHeaders(_:) -> RequestHeaderUpdateOutcomereplaces a live session's request headers. The next request from each of the session's source readers carries the new set. Nothing is torn down.The motivating case is a media server whose bearer tokens expire under a long title. Until now the only way to get a renewed token onto the wire was
reloadAtCurrentPosition(applying:), which is a visible rebuild at the playhead to change a value only the next request reads.How
RequestHeaderStore: a lock-protected box, one perload, created fromoptions.httpHeaders.AVIOReadertakes an optional store and readsextraHeadersfrom it per request. Every request path already goes throughheaders(for:), so the redirect policy, the held connection and the probe and chunk delegates all see the current value with no other change. Readers opened without a store (probes, sidecars, stills, prewarm) behave exactly as before.DemuxerOpenProfile.requestHeaders/withRequestHeaders(_:)carry the store throughDemuxer.open. Its signature is unchanged.HLSVideoEnginestart, restart-reopen and live-reopen opens and the I-frame side reader (sourceHTTPHeadersis now read from the store), and the subtitle prefetch and native-subtitle side readers.setLoadedHTTPHeaders(_:)is the fifth narrow write intoloadedOptions, so rebuilds (an audio switch, a background return,reloadAtCurrentPosition()) replay the new set..installedForNextRebuild:.remoteBypass, an AVPlayer-hosted audio item, a customIOReader, and a remote disc image (HTTPDiscIOReaderis not wired). A call with nothing loaded answers.noActiveSessionand installs nothing.Part 2 of #792 (a typed
sourceRefusedand a shorter ladder for a mid-session 401) is not in this PR. It changes how the revive arm classifies failures, so it seemed better shaped by you.Test plan
macOS 27 (arm64), Xcode 27 release toolchain,
swift buildandswift test.LiveRequestHeaderTests:requestHeaderStore: nil), the same test fails after 83 s: the reader spends its 12-step reconnect ladder on the refused token and the read fails. That is the stall the issue describes..noActiveSessioninstalls nothing.PublicAPIDocumentationTestsandDocumentedConstantsTests.Scripts/check-doc-links.py: all links resolve.