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

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

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/http/intercepted_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class InterceptedClient extends BaseClient {

@override
Future<StreamedResponse> send(BaseRequest request) async {
final response = await _attemptRequest(request);
final response = await _attemptRequest(request, isStream: true);

final interceptedResponse = await _interceptResponse(response);

Expand Down Expand Up @@ -266,7 +266,8 @@ class InterceptedClient extends BaseClient {

/// Attempts to perform the request and intercept the data
/// of the response
Future<BaseResponse> _attemptRequest(BaseRequest request) async {
Future<BaseResponse> _attemptRequest(BaseRequest request,
{bool isStream = false}) async {
BaseResponse response;
try {
// Intercept request
Expand All @@ -278,8 +279,7 @@ class InterceptedClient extends BaseClient {
.send(interceptedRequest)
.timeout(requestTimeout!, onTimeout: onRequestTimeout);

response =
request is Request ? await Response.fromStream(stream) : stream;
response = isStream ? stream : await Response.fromStream(stream);

if (retryPolicy != null &&
retryPolicy!.maxRetryAttempts > _retryCount &&
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
sdk: ">=3.0.3 <4.0.0"

dependencies:
http: ^1.0.0
http: ^1.1.0

dev_dependencies:
lints: ^2.1.1
Expand Down