http_interceptor
http_interceptor copied to clipboard
type 'Response' is not a subtype of type 'StreamedResponse' in type cast
Describe the bug
Hey guys, I'm using ^2.0.0-beta.7. I have this error in two cases (100% of time):
- Any time I use send method in the client (https://pub.dev/documentation/http/latest/http/Client/send.html)
- When I provide client to the
CacheManager's config here: https://pub.dev/documentation/flutter_cache_manager/latest/flutter_cache_manager/HttpFileService/HttpFileService.html
It looks like it somehow just force casts and crashes every time here: https://github.com/CodingAleCR/http_interceptor/blob/main/lib/http/intercepted_client.dart#L222
Expected behavior No crashes
Please complete the following information):
- Flutter version: 3.10.5
- IDE: Android Studio
http_interceptorVersion: ^2.0.0-beta.7
I'll have to fork because of this. The Response shouldn't be casted to StreamedResponse specially when the shouldInterceptResponse is set to false.
I don't know how I missed this and it has stayed like this so long. Thank you for reporting it and for the subsequent comment that surfaced this. I'll look into it as soon as possible.
PRs are welcomed in any case if you also find a fix for this. 🙏🏻
So, a bit of an insight for future me:
Your CacheManager uses a HttpFileService that underneath makes use of send. So fixing send should be enough of a fix for both scenarios.
I got a follow up question for you both @miguelruivo @antonshkurenko, what type of request are you sending into send? I ask because send is expected always to return a StreamedResponse (that's coming from http not something from this library) so I don't think the casting is the issue, that's why I want to make sure things are working properly and your answer would help me figure out things. Either that or a repository where I can replicate the issue would be appreciated.
Another ask is if it's still happening on 2.0.0 stable release. There was a pre-release 2.0.0-beta.8 that never got released and had a fix for this.
I'll add the PR for reference #132