Skip to content
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

type 'Response' is not a subtype of type 'StreamedResponse' in type cast #134

Open
antonshkurenko opened this issue Aug 27, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@antonshkurenko
Copy link

Describe the bug
Hey guys, I'm using ^2.0.0-beta.7. I have this error in two cases (100% of time):

  1. Any time I use send method in the client (https://pub.dev/documentation/http/latest/http/Client/send.html)
  2. 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_interceptor Version: ^2.0.0-beta.7
@antonshkurenko antonshkurenko added the bug Something isn't working label Aug 27, 2023
@miguelruivo
Copy link

I'll have to fork because of this. The Response shouldn't be casted to StreamedResponse specially when the shouldInterceptResponse is set to false.

@CodingAleCR
Copy link
Owner

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. 🙏🏻

@CodingAleCR
Copy link
Owner

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.

@CodingAleCR
Copy link
Owner

CodingAleCR commented Jul 11, 2024

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.

@CodingAleCR
Copy link
Owner

I'll add the PR for reference #132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants