Skip to content

Commit

Permalink
🎨 Reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Jun 19, 2024
1 parent 70337e9 commit 759363c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions dio/lib/src/adapters/io_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,23 @@ class IOHttpClientAdapter implements HttpClientAdapter {
);
}
final operation = CancelableOperation.fromFuture(
_fetch(
options,
requestStream,
cancelFuture,
),
_fetch(options, requestStream, cancelFuture),
);

if (cancelFuture != null) {
cancelFutureOperationPool.putIfAbsent(cancelFuture, () => {});
cancelFutureOperationPool[cancelFuture]!.add(operation);
cancelFutureRequestPool.putIfAbsent(cancelFuture, () => {});

cancelFuture.whenComplete(() {
cancelFutureOperationPool[cancelFuture]?.forEach((e) => e.cancel());
cancelFutureOperationPool.remove(cancelFuture);
cancelFutureRequestPool[cancelFuture]?.forEach((e) => e.abort());
cancelFutureRequestPool.remove(cancelFuture);
});

cancelFutureOperationPool[cancelFuture]!.add(operation);
}

return operation.value.whenComplete(
() => cancelFutureOperationPool[cancelFuture]?.remove(operation),
);
Expand Down Expand Up @@ -119,12 +122,7 @@ class IOHttpClientAdapter implements HttpClientAdapter {
}

if (cancelFuture != null) {
cancelFutureRequestPool.putIfAbsent(cancelFuture, () => {});
cancelFutureRequestPool[cancelFuture]!.add(request);
cancelFuture.whenComplete(() {
cancelFutureRequestPool[cancelFuture]?.forEach((e) => e.abort());
cancelFutureRequestPool.remove(cancelFuture);
});
}

// Set Headers
Expand Down

0 comments on commit 759363c

Please sign in to comment.