-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alamofire 5.0.0-rc.3 RequestInterceptor Adapt method not being called of Alamofire although retry gets called when there is any error in response. #2998
Comments
`
} `
` |
Might be worth checking the method signature of your adapt method. I think it should be: whereas your method is: I believe |
Tried with that method as well still not getting called |
@kst01 it has to be that your method signature is incorrect. There's default implementations for |
I've experienced runtime issues with this method before, when it was being called from a file which imported an additional typealias AdapterResult = Swift.Result<URLRequest, Error>
... in adapter ...
func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (AdapterResult) -> Void) { } This may be fixed in newer Swift compilers but I thought I'd mention it just in case. |
Thanks @jshier! |
Thanks soo much jshier, this is what was causing the issue. Thanks a lot for the fix as well. |
@kst01 Out of curiosity, did you have another |
Yes but not in same class. |
I using func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Swift.Result<URLRequest, Error>) -> Void) { (Added |
Adding to this, be careful of not putting your custom interceptor classes in extensions, that also does not work. |
Adding more to this... Make sure ALL parameters received by either of these functions are not overridden or explicitly disambiguate
In my case I used Error so I had to disambiguate with Swift.Error My interceptor is going to remain this way just for accident sake. |
What did you do?
Created a class conforming to RequestInterceptor protocol and implemented adapt & retry delegate methods.
What did you expect to happen?
Adapt method to get called where in i can add tokens to request headers.
What happened instead?
adapt method didnt get called, although retry gets called in case there is an error in the response.
Alamofire Environment
Alamofire version: Alamofire 5.0.0-rc.3
Xcode version: 11.0
Swift version: 5.0
Platform(s) running Alamofire: iOS
macOS version running Xcode: 10.14.6
Archive.zip
The text was updated successfully, but these errors were encountered: