mirror of
https://github.com/dirtydishes/dreamio.git
synced 2026-06-07 05:48:15 +00:00
bound range cache probe startup
This commit is contained in:
parent
4d0e675aa3
commit
4b173e0b88
6 changed files with 254 additions and 5 deletions
|
|
@ -44,6 +44,7 @@ struct StreamResolverTests {
|
|||
await testRangeCacheForegroundMissReprioritizesPrefetch()
|
||||
await testRangeCacheHitFollowsActualPostSeekReadArea()
|
||||
await testRangeProbeAllowsRangeCacheForMKVWhenServerSupportsRanges()
|
||||
await testRangeProbeAppliesRequestTimeout()
|
||||
await testRangeProbeFallsBackWhenServerIgnoresRange()
|
||||
await testRangeFetcherPreservesHeaders()
|
||||
print("StreamResolverTests passed")
|
||||
|
|
@ -572,6 +573,32 @@ struct StreamResolverTests {
|
|||
MockURLProtocol.handler = nil
|
||||
}
|
||||
|
||||
private static func testRangeProbeAppliesRequestTimeout() async {
|
||||
MockURLProtocol.handler = { request in
|
||||
assertEqual(request.timeoutInterval, 1.5)
|
||||
let response = HTTPURLResponse(
|
||||
url: request.url!,
|
||||
statusCode: 200,
|
||||
httpVersion: nil,
|
||||
headerFields: [
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Length": "20"
|
||||
]
|
||||
)!
|
||||
return (Data(), response)
|
||||
}
|
||||
|
||||
let fetcher = HTTPRangeRemoteFetcher(
|
||||
url: URL(string: "https://cdn.example.test/show.mkv")!,
|
||||
headers: [:],
|
||||
session: mockSession()
|
||||
)
|
||||
let probe = await fetcher.probe(timeoutInterval: 1.5)
|
||||
|
||||
assertEqual(probe.isCacheable, true)
|
||||
MockURLProtocol.handler = nil
|
||||
}
|
||||
|
||||
private static func byteRange(fromHeader header: String, contentLength: Int64) -> HTTPByteRange {
|
||||
let value = header.replacingOccurrences(of: "bytes=", with: "")
|
||||
let pieces = value.split(separator: "-", maxSplits: 1).map(String.init)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue