PreprocessHttpRequestDelegate
@available(*, deprecated, message: "Use NetworkConfig.preprocessHttpRequest instead.")
@objc(BMPPreprocessHttpRequestDelegate)
public protocol PreprocessHttpRequestDelegate
A delegate protocol that can be used to change request parameters before a request is made.
- Example implementation of
PreprocessHttpRequestDelegate.
class MyPreprocessHttpRequestDelegate: PreprocessHttpRequestDelegate {
func preprocessHttpRequest(
_ type: String,
httpRequest: HttpRequest,
completionHandler: @escaping (_ httpRequest: HttpRequest) -> Void
) {
var modifiedRequest = httpRequest
// Modify the request based on the type
switch type {
case HttpRequestType.drmLicenseFairplay.rawValue:
// Example modification for DRM requests
modifiedRequest.headers["Authorization"] = "Bearer someAccessToken"
case HttpRequestType.manifestHlsMaster.rawValue:
// Example modification for HLS Playlist requests
modifiedRequest.url = modifiedRequest.url.appendingPathComponent("modified")
default:
break
}
// Call the completion handler with the modified request
completionHandler(modifiedRequest)
}
}
-
Can be used to change request parameters before a request is made.
Limitations
- Requests of type
HttpRequestType.keyHlsAesare not supported. - Requests of type
HttpRequestType.mediaSubtitlesare only supported in case the subtitles are side-loaded.
Declaration
Swift
@objc func preprocessHttpRequest( _ type: String, httpRequest: HttpRequest, completionHandler: @escaping (_ httpRequest: HttpRequest) -> Void )Parameters
typeThe type of the request to be made. Possible values are defined in
HttpRequestType.httpRequestThe configuration object of the request.
completionHandlerA completion handler that must be called with the modified
HttpRequest. Not calling the completion handler prevents the HTTP request from being sent and blocks the player. - Requests of type
PreprocessHttpRequestDelegate Protocol Reference