Fix "type 'Response' is not a subtype of type 'StreamedResponse' in type cast" after retrying a request #155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue description:
When you use the library in version
2.0.0
and create theInterceptedClient
with aretryPolicy
and then call thesend()
method it throws a"type 'Response' is not a subtype of type 'StreamedResponse' in type cast"
exception after theretryPolicy
was used to retry the request.Proposed fix:
After #132 the
_attemptRequest()
method has received an optional parameterisStream
set by default tofalse
. When theretryPolicy
is invoked inside the method, the_attemptRequest()
is recursively called again but theisStream
parameter isn't passed through, but rather the default value is being used. Due to that even if you call_attemptRequest(isStream: true)
then after usingretryPolicy
it will be called again but with the default valuefalse
, which then leads to the type cast error.Hopefully, it could possibly fix the #134 if it isn't resolved already 😉