Skip to content

Commit

Permalink
fix: fixed hashcode issue for chopper
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlala committed Nov 12, 2023
1 parent 541d6bf commit a5818d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* [BREAKING_CHANGE] Updated dart min version to 3.0.0.
* [BREAKING_CHANGE] Removed `darkTheme` parameter. Alice will now automatically detect the color scheme.
* [BREAKING_CHANGE] Alice will now return chopper interceptor instance instead of list with that interceptor.
* Fixed issue with the same http call not properly handled with chopper. Alice will add "alice_token" to the headers of the request to identify given http call.
* Updated dependencies.
* Fixed lints.
* Updated example.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ chopper = ChopperClient(
);
```

Attention! Alice will add special "alice_token" header to the request in order to calculate correct id for the http call.

If you have other HTTP client you can use generic http call interface:
```dart
AliceHttpCall aliceHttpCall = AliceHttpCall(id);
Expand Down
6 changes: 5 additions & 1 deletion lib/core/alice_chopper_response_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class AliceChopperInterceptor
@override
FutureOr<chopper.Request> onRequest(chopper.Request request) async {
try {
final baseRequest = await request.toBaseRequest();
final headers = request.headers;
headers['alice_token'] = DateTime.now().millisecondsSinceEpoch.toString();
final changedRequest = request.copyWith(headers: headers);
final baseRequest = await changedRequest.toBaseRequest();

final call = AliceHttpCall(getRequestHashCode(baseRequest));
var endpoint = '';
var server = '';
Expand Down

0 comments on commit a5818d3

Please sign in to comment.