PreprocessHttpRequestDelegate

@available(*, deprecated, message: "Use NetworkConfig.preprocessHttpRequest instead.")
@objc(BMPPreprocessHttpRequestDelegate)
public protocol PreprocessHttpRequestDelegate : Sendable

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.keyHlsAes are not supported.
    • Requests of type HttpRequestType.mediaSubtitles are only supported in case the subtitles are side-loaded.

    Declaration

    Swift

    @objc
    func preprocessHttpRequest(
        _ type: String,
        httpRequest: HttpRequest,
        completionHandler: @escaping (_ httpRequest: HttpRequest) -> Void
    )

    Parameters

    type

    The type of the request to be made. Possible values are defined in HttpRequestType.

    httpRequest

    The configuration object of the request.

    completionHandler

    A 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.