title: AVPlayer playing protected HLS, how to update token when it expires?
body: <p>Im playing the protected HLS streams and my token expires in 5 minutes, so each time stream drops when token expires and I'm getting an error 401 Unauthorized. Question is how to update the token inside asset? I've already tried to change it in resourceLoader loadingRequest.allHTTPHeaderFields but it didn't help:</p>
  <pre><code>  func resourceLoader(_ resourceLoader: AVAssetResourceLoader,
                              shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -&gt; Bool {
          
  DispatchQueue.main.async { [unowned self] in
                  var request = loadingRequest.request
                  let service = apiService as! APIServiceImplementation
                  
                  service.networkService.resfreshToken { result in
                      let data = apiService.prepareForLiveRequest(url: request.url!)
                      request.url = data.url
                      var mergedHeaders = request.allHTTPHeaderFields
                      mergedHeaders![&quot;Cookie&quot;] = (data.1.values.first! as! [String: String])[&quot;Cookie&quot;]
                      request.allHTTPHeaderFields = mergedHeaders
                      URLSession(configuration: URLSessionConfiguration.default).dataTask(with: request) {
                          data, response, error in
                          if let error = error {
                              print(error)
                              loadingRequest.finishLoading(with: error)
                          } else {
                              loadingRequest.dataRequest?.respond(with: data!)
                              loadingRequest.finishLoading()
                          }
                      }.resume()
                  }
              }
              return true
          }
  </code></pre>