The question is why you need to verify the correctness. If you only want to verify the correctness, you can probably use an unusual method, using URLProtocol
and writing a custom one NSURLProtocolClient
. The client has only empty methods, except:
func urlProtocol(_ protocol: URLProtocol, cachedResponseIsValid cachedResponse: CachedURLResponse) {
// Cached response is valid. Store this information in a appropriate way.
protocol.stopLoading()
}
Now you are creating a protocol with this client
let myClient = ...
let protocol = NSURLProtocol(request, cachedResponse, client: myClient)
protocol.startLoading()
protocol.stopLoading() // Stop, if urlProtocol(_: cachedResponseIsValid:) was not called
source
share