Comments (9)
Solution found: #6
Just needed to append InterceptingProtocol
to protocol classes and not assigning new array like suggested in Usage
configuration.protocolClasses?.insert(InterceptingProtocol.self, atIndex: 0)
from responsedetective.
Thanks for noticing! 🍷
from responsedetective.
I'm having this problem while using the new suggested way of adding the protocol class with Alamofire
.
from responsedetective.
I fixed this by using append
rather than insert: atIndex:
Edit: Scratch that. This doesn't fix it. This allows the requests to work, but stops intercepting the requests.
from responsedetective.
Are you using anything else that do something with protocolClasses
?
from responsedetective.
Here is the code that is setting up my configuration:
let networkManager: Manager = {
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.HTTPAdditionalHeaders = Manager.defaultHTTPHeaders
configuration.protocolClasses = map(configuration.protocolClasses, { (var protocolClasses) in
protocolClasses.insert(InterceptingProtocol.self, atIndex: 0)
return protocolClasses
}) ?? [InterceptingProtocol.self]
return Manager(configuration: configuration, serverTrustPolicyManager: nil)
}()
The configuration's protocolClasses
array contains:
ResponseDetective.InterceptingProtocol,
_NSURLHTTPProtocol,
_NSURLDataProtocol,
_NSURLFTPProtocol,
_NSURLFileProtocol,
NSAboutURLProtocol
I'm going to continue attempting to debug this this morning, but I'm pretty lost at the moment.
It may be worth noting that I'm making HTTPS requests. I know there were issues in the past with that.
I'm also using the commit tagged for version 0.2
from responsedetective.
It seems that stopLoading
is being called, which is canceling the request. But when I check out the response
in the debugger, I see that the response from the server is there. I just also have an error NSURLErrorDomain code=-999 "canceled"
Because there is an error, my validation is failing.
ResponseDetective
is also never logging the responses.
from responsedetective.
@AnthonyMDev I will investigate that. Could you provide me with a sample project?
from responsedetective.
Hi everyone, I came back to this issue recently and found out that cancellation happens because of Alamofire.Manager.deinit
which invalidates the session, which triggers a chain reaction of cancelling all requests.
The following code:
let manager = Alamofire.Manager()
manager.request(.GET, "https://httpbin.org/get").response { _, _, _, error in
print(error)
}
will always fail with NSURLErrorCancelled
code, even with ResponseDetective
disabled, because manager
is deallocated before the request even starts loading.
In order for Manager
to complete the tasks successfully, its instance needs to be retained (e.g. in a private property). This also makes ResponseDetective work again.
I'm closing this issue as it has been tested with retained Alamofire.Manager
in the upcoming 0.4 release.
from responsedetective.
Related Issues (20)
- Move console logging to a background thread
- Request Body is always <none> in Content-Type: multipart/form-data; HOT 3
- Support for multipart/form-data requests
- Improve printing of empty, unrecognizable and non-raw bodies
- Support for Xcode 9 HOT 1
- Hide Objective-C nature of XML and HTML body deserializers HOT 1
- Unsupported on Carthage 0.26.2 HOT 1
- The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor. HOT 12
- Not compatible with Swift 4.1 on Xcode 9.3 targeting iOS 11.3 HOT 1
- Update Cocoapods to 1.2.3 HOT 3
- Carthage *** Skipped installing ResponseDetective.framework binary due to the error: HOT 4
- umbrella header not found for static library HOT 1
- Add response filtering method. HOT 1
- Crash on iOS 13.4 (EXC_BAD_ACCESS) HOT 2
- Push version 1.4.0 to CocoaPods HOT 1
- Runtime crash HOT 1
- Hey HOT 2
- Issue when using ResponseDetective with Carthage HOT 4
- Trace/BPT trap:5 error since XCode 13.3 HOT 2
- Some Requests are getting cancelled when Response Detective is enabled HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from responsedetective.