You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-2Lines changed: 34 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ A lightweight wrapper to the [JDK 11+ Java Http Client](http://openjdk.java.net/
24
24
<dependency>
25
25
<groupId>io.avaje</groupId>
26
26
<artifactId>avaje-http-client</artifactId>
27
-
<version>1.17</version>
27
+
<version>${avaje.client.version}</version>
28
28
</dependency>
29
29
```
30
30
@@ -63,7 +63,7 @@ From HttpClientContext:
63
63
64
64
65
65
## Limitations:
66
-
-NO support for POSTing multipart-form currently
66
+
-No support for POSTing multipart-form currently
67
67
- Retry (when specified) does not apply to `async` response processing`
68
68
69
69
@@ -299,7 +299,39 @@ HttpResponse<Void> res = clientContext.request()
299
299
assertThat(res.statusCode()).isEqualTo(201);
300
300
```
301
301
302
+
## Retry (Sync Requests Only)
303
+
To add Retry funtionality, use `.retryHandler(yourhandler)` on the builder to provide your retry handler. The `RetryHandler` interface provides two methods, one for status exceptions (e.g. you get a 4xx/5xx from the server) and another for exceptions thrown by the underlying client (e.g. server times out or client couldn't send request). Here is example implementation of `RetryHandler`.
302
304
305
+
```
306
+
public final class ExampleRetry implements RetryHandler {
307
+
private static final int MAX_RETRIES = 2;
308
+
@Override
309
+
public boolean isRetry(int retryCount, HttpResponse<?> response) {
310
+
311
+
final var code = response.statusCode();
312
+
313
+
if (retryCount >= MAX_RETRIES || code >= 400) {
314
+
315
+
return false;
316
+
}
317
+
318
+
return true;
319
+
}
320
+
321
+
@Override
322
+
public boolean isExceptionRetry(int retryCount, HttpException response) {
0 commit comments