File tree Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ extension AddParameters on Uri {
1919 newParameters[key] = value;
2020 });
2121
22- return buildUrlString (paramUrl, newParameters).toUri ();
22+ String finalUrl = buildUrlString (paramUrl, newParameters);
23+
24+ // Preserve the fragment if it exists
25+ if (fragment.isNotEmpty) {
26+ finalUrl += '#$fragment ' ;
27+ }
28+
29+ return finalUrl.toUri ();
2330 }
2431}
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ class InterceptedClient extends BaseClient {
293293 _retryCount += 1 ;
294294 await Future .delayed (retryPolicy!
295295 .delayRetryAttemptOnResponse (retryAttempt: _retryCount));
296- return _attemptRequest (request);
296+ return _attemptRequest (request, isStream : isStream );
297297 }
298298 } on Exception catch (error) {
299299 if (retryPolicy != null &&
@@ -302,7 +302,7 @@ class InterceptedClient extends BaseClient {
302302 _retryCount += 1 ;
303303 await Future .delayed (retryPolicy!
304304 .delayRetryAttemptOnException (retryAttempt: _retryCount));
305- return _attemptRequest (request);
305+ return _attemptRequest (request, isStream : isStream );
306306 } else {
307307 rethrow ;
308308 }
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ abstract class RetryPolicy {
4545 FutureOr <bool > shouldAttemptRetryOnResponse (BaseResponse response) => false ;
4646
4747 /// Number of maximum request attempts that can be retried.
48- final int maxRetryAttempts = 1 ;
48+ int get maxRetryAttempts => 1 ;
4949
5050 Duration delayRetryAttemptOnException ({required int retryAttempt}) =>
5151 Duration .zero;
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ main() {
1212 test ("defaults to 1" , () {
1313 expect (testObject.maxRetryAttempts, 1 );
1414 });
15+
16+ test ("can be overridden" , () {
17+ testObject = TestRetryPolicy (
18+ maxRetryAttempts: 5 ,
19+ );
20+
21+ expect (testObject.maxRetryAttempts, 5 );
22+ });
1523 });
1624
1725 group ("delayRetryAttemptOnException" , () {
@@ -60,4 +68,13 @@ main() {
6068 });
6169}
6270
63- class TestRetryPolicy extends RetryPolicy {}
71+ class TestRetryPolicy extends RetryPolicy {
72+ TestRetryPolicy ({
73+ int maxRetryAttempts = 1 ,
74+ }) : internalMaxRetryAttempts = maxRetryAttempts;
75+
76+ final int internalMaxRetryAttempts;
77+
78+ @override
79+ int get maxRetryAttempts => internalMaxRetryAttempts;
80+ }
You can’t perform that action at this time.
0 commit comments