Assertion Failure when using file URLs
kenjitayama opened this issue Β· comments
I get this assertion failure when using file URLs.
Fatal error: Only support HTTPURLResponse: file Atlantis/Packages.swift, line 209
It can be reproduced with this code in an iOS app.
if let url = Bundle.main.url(forResource: "Info", withExtension: "plist") {
let task = URLSession.shared.downloadTask(with: url)
task.resume()
}
In our app, many resources are retrieved from a web server, while some are bundled in the app.
For a specific kind of resource, we want to use the same implementation for web and bundled file, which uses URLSessionDownloadTask.
It would be helpful if this assertionFailure is removed.
Thanks for opening this issue. I'm looking at it and remove it as possible π
Hey @kenjitayama,
Can you share with us:
- Which iOS are you using?
- If you don't mind, can you provide a sample of your URL?
I tried to reproduce but it's working fine (Proxyman 2.15.1, iOS 14 and Atlantis 1.4.3)
let url = URL(string: "https://proxyman.io/img/background/proxyman-dashboard-home.png")!
let task = URLSession.shared.downloadTask(with: url)
task.resume()
let url = URL(string: "https://proxyman.io/img/background/proxyman-dashboard-home.png")!
let task = URLSession.shared.downloadTask(with: url) { (_, response, error) in
if let error = error {
print(error)
return
}
if let response = response as? HTTPURLResponse {
print(response)
}
}
task.resume()
Both URLSessionDownloadTasks are still working
One more thing, when the assertionFailure
occurs, can you print out the type of response variable?
The easier way is that you set the breakpoint at Atlantis/Packages.swift, line 209
and type po response
to see the type and content.
@NghiaTranUIT Thanks for checking the issue!!
- Which iOS are you using?
I am using iOS 14.0 and Atlantis 1.4.3.
- If you don't mind, can you provide a sample of your URL?
One more thing, when the assertionFailure occurs, can you print out the type of response variable?
Did this when assertionFailure occured (I changed the app name in the URL):
(lldb) po response
(NSURLResponse *) <0x283ec00e0> <NSURLResponse: 0x283ec00e0> { URL: file:///private/var/containers/Bundle/Application/CC649D79-6DC8-4B10-A4BA-E01A39E2275E/Example.app/Info.plist }
You need to use a file://
URL to reproduce.
Thanks. I'm able to reproduce this bug. Fixing now π
@kenjitayama please check out the 1.5.0 version, which I've released (https://github.com/ProxymanApp/atlantis/releases/tag/1.5.0)
It fixes your problem π Thank you and Merry Christmas π
@NghiaTranUIT Thanks for the quick fix!
Confirmed the issue is resolved in our app.
It's nice that we could see file://
URLs in Proxyman too π
Merry Christmas π
Glad to know it works π