Skip to content

Commit

Permalink
fix: type 'Response' is not a subtype of type 'StreamedResponse' in t…
Browse files Browse the repository at this point in the history
…ype cast (#132)

Co-authored-by: wilinz <weiizan71@gmail.com>
  • Loading branch information
wilinz and wilinz authored Oct 9, 2023
1 parent f7f9649 commit 808da34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit 808da34

Please sign in to comment.