File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -207,9 +207,9 @@ extension Atlantis {
207
207
#endif
208
208
}
209
209
210
- private func checkShouldIgnoreByURLProtocol( on request: URLRequest ) -> Bool {
210
+ private func checkShouldIgnoreByURLProtocol( protocols : [ AnyClass ] , on request: URLRequest ) -> Bool {
211
211
// Get the BBHTTPProtocolHandler class by name
212
- for cls in ignoreProtocols {
212
+ for cls in protocols {
213
213
214
214
// Get the canInitWithRequest: selector
215
215
let selector = NSSelectorFromString ( " canInitWithRequest: " )
@@ -259,8 +259,16 @@ extension Atlantis {
259
259
return nil
260
260
}
261
261
262
+ // Just check ignore protocols if it's not empty and the session resumes the task has this protocol
263
+ var sessionProtocols : [ AnyClass ] = [ ]
264
+ if !ignoreProtocols. isEmpty, let session = task. value ( forKey: " session " ) as? URLSession {
265
+ let protocols = Set ( ( session. configuration. protocolClasses ?? [ ] ) . map { NSStringFromClass ( $0) } )
266
+ let shouldIgnores = Set ( ignoreProtocols. map { NSStringFromClass ( $0) } )
267
+ sessionProtocols = protocols. intersection ( shouldIgnores) . compactMap { NSClassFromString ( $0) }
268
+ }
269
+
262
270
// check should ignore this request because it's duplicated by URLProtocol classes
263
- if checkShouldIgnoreByURLProtocol ( on: request) {
271
+ if checkShouldIgnoreByURLProtocol ( protocols : sessionProtocols , on: request) {
264
272
ignoredRequestIds. insert ( id)
265
273
return nil
266
274
}
You can’t perform that action at this time.
0 commit comments