Posts

Post not yet marked as solved
4 Replies
3k Views
If I make a request for a file with the "Range" header specified using iOS's URLSession then it will correctly give me this range. However, if I then request the same file without a "Range" header, I receive the same response as the ranged request. This is the case even if I request a different byte range on the same file.Here's an example:let url = "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/3340/33409.ts" let session = URLSession.shared let u = URL(string:url)! var request = URLRequest(url: u) request.addValue("bytes=10-19", forHTTPHeaderField: "Range") session.dataTask(with: request) {(data, response, error) in let response = response as! HTTPURLResponse print("Ranged with response: \(response.statusCode) \(response.allHeaderFields)") var request = URLRequest(url: u) request.addValue("bytes=20-49", forHTTPHeaderField: "Range") session.dataTask(with: request) {(data, response, error) in let response = response as! HTTPURLResponse print("Full request with response: \(response.statusCode) \(response.allHeaderFields)") }.resume() }.resume()I'd like to be able to request a range and then another range later, on the same file. Is there any way to do this without turning off local caching completely?
Posted Last updated
.