Add custom HTTP headers

Authorize your content request with HTTP headers.


If your content server allows for HTTP header authentication, you can apply HTTP headers to your self-hosted, registered content. HTTP headers prevent unauthorized downloads of your content.


To authorize your content request with HTTP headers, use the following steps:

  1. Create a Map<String, String> object and name it, for example, httpHeaders.
  2. Define httpHeaders.
  3. Add httpHeaders to a PlaylistItem.
// Create a list to contain the PlaylistItems
List<PlaylistItem> playlist = new ArrayList<>();

// Create key-value map for the HTTP headers
Map<String, String> httpHeaders = new HashMap<>();
httpHeaders.put("cookie", "abcd1234");
        
// Add a PlaylistItem pointing to the first piece of content
PlaylistItem content = new PlaylistItem.Builder()
    .file("http://content/http-header-protected-content.m3u8")
    .httpHeaders(httpHeaders)
    .build();
        
// Add the content to the playlist
playlist.add(content);


Did this page help you?