You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a problems with atlantis when run it in the app that use URLProtocol. Because the app is blackbox so I can't show the code, but I can reproduce it with my guess code
import SwiftUI
import Foundation
finalclassMyProtocol:URLProtocol{overrideclassfunc canInit(with request:URLRequest)->Bool{
if request.allHTTPHeaderFields?["Custom-Header"]=="Test value"{return false
}return true
}overrideclassfunc canonicalRequest(for request:URLRequest)->URLRequest{varrequest= request
request.addValue("Test value", forHTTPHeaderField:"Custom-Header")return request
}overridefunc startLoading(){URLSession.shared.dataTask(with: request){ data, response, error in
if let error {self.client?.urlProtocol(self, didFailWithError: error)}else if let response {self.client?.urlProtocol(self, didReceive: response, cacheStoragePolicy:.notAllowed)
if let data {self.client?.urlProtocol(self, didLoad: data)}}self.client?.urlProtocolDidFinishLoading(self)}.resume()}overridefunc stopLoading(){}}structContentView:View{privateletsession:URLSessioninit(){URLProtocol.registerClass(MyProtocol.self)letconfig=URLSessionConfiguration.default
config.protocolClasses =[MyProtocol.self]
session =URLSession(configuration: config)}varbody:someView{VStack{Button("Httpbin"){Task{do{let(_, response)=tryawait session.data(from:URL(string:"https://httpbin.org/get")!)print(response)}catch{print(error)}}}}.padding()}}```
When I run this code, and tap to Httpbin, Atlantis will capture 2 records, one has"Custom-Header", one not
The text was updated successfully, but these errors were encountered:
Hi, I have a problems with atlantis when run it in the app that use URLProtocol. Because the app is blackbox so I can't show the code, but I can reproduce it with my guess code
The text was updated successfully, but these errors were encountered: