Skip to content

Send request headers with each asset, and let apps adjust each WebView - #57

Merged
514sid merged 1 commit into
mainfrom
request-headers
Nov 25, 2026
Merged

514sid merged 1 commit into
mainfrom
request-headers

Conversation

@514sid

@514sid 514sid commented Nov 25, 2026

Copy link
Copy Markdown
Owner

GaplessAsset.requestHeaders are sent with every request for an asset:

  • video: the HLS or DASH manifest, segments and progressive files, through a ResolvingDataSource that reads the slot's headers per request
  • images: through Coil's httpHeaders
  • web pages: with the main document's load. Subresources and later navigations don't carry them, since WebView offers no way to add headers there; an app that needs that can use its own WebViewClient (below).

Header names must be non-blank with no whitespace or :, and values can't contain CR or LF. Both are checked when the playlist is set.

GaplessWebConfig.configureWebView is called with each WebView once the library has set it up and before it loads anything, including the WebView that replaces one whose renderer crashed. An app can change any setting, set its own WebChromeClient, or add a JavaScript interface. A WebViewClient of its own works too: the library keeps its client on the WebView and passes every callback on to the app's, so shouldInterceptRequest (offline pages) and onReceivedHttpAuthRequest (basic auth) work. onRenderProcessGone isn't passed on, since the library replaces the crashed WebView itself. If the function turns JavaScript off or removes the gapless interface, the library turns them back on and logs a warning. If it throws, the error is logged and the WebView is used as the library set it up.

The sample app gets an HLS sample and a network playlist. With --es server and --es header, the sample assets are fetched from a local server with that header, which showed the header arriving on the HLS manifest and segments, the MP4, the image and the page on both TVs.

GaplessAsset.requestHeaders are sent with every request for the asset: the
video's manifest and segments, the image, and the web page's main document.
Header names and values are checked when the playlist is set.

GaplessWebConfig.configureWebView is called with each WebView once the
library has set it up, including a WebView that replaces a crashed one. An
app can change any setting, set its own WebChromeClient, or set its own
WebViewClient: the library keeps its client on the WebView and passes every
callback on to the app's, except onRenderProcessGone. JavaScript and the
gapless interface are turned back on if the function removes them.

The sample app gets an HLS sample and a network playlist that plays from a
local server with a header.
@514sid
514sid merged commit bd818bd into main Nov 25, 2026
1 check passed
@514sid
514sid deleted the request-headers branch November 25, 2026 12:15
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.

1 participant