Skip to content

Commit 6244b22

Browse files
committed
Update README
1 parent 57cec89 commit 6244b22

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# avaje-http-client
22

3-
A light weight wrapper to the JDK 11+ Java Http Client
3+
A light weight wrapper to the [JDK 11+ Java Http Client](http://openjdk.java.net/groups/net/httpclient/intro.html)
44

55
- Adds a fluid API for request constructing URL and payload
66
- Adds JSON marshalling/unmarshalling of request and response using Jackson or Gson
@@ -58,6 +58,16 @@ From HttpClientContext:
5858

5959
## Limitations:
6060
- NO support for POSTing multipart-form currently
61+
- Retry (when specified) does not apply to `async` response processing`
62+
63+
64+
## JDK HttpClient
65+
66+
- Introduction to JDK HttpClient at
67+
[JDK HttpClient Introduction](http://openjdk.java.net/groups/net/httpclient/intro.html)
68+
69+
- Javadoc for JDK
70+
[HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html)
6171

6272

6373
#### Example GET as String
@@ -91,13 +101,13 @@ Overview of response types for sync calls.
91101
<tr><td>withHandler(HttpResponse.BodyHandler&lt;E&gt)</td><td>CompletableFuture&lt;HttpResponse&lt;E&gt;&gt;</td></tr>
92102
</table>
93103

94-
### JDK BodyHandlers
104+
### HttpResponse BodyHandlers
95105

96-
JDK HttpClient provides a number of BodyHandlers including reactive Flow based subscribers.
97-
With the `withHandler()` methods we can use any of these or our own `HttpResponse.BodyHandler`
106+
JDK HttpClient provides a number of [BodyHandlers](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.BodyHandler.html)
107+
including reactive Flow based subscribers. With the `withHandler()` method we can use any of these or our own [`HttpResponse.BodyHandler`](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.BodyHandler.html)
98108
implementation.
99109

100-
Reference https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.BodyHandlers.html
110+
Refer to [HttpResponse.BodyHandlers](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.BodyHandlers.html)
101111

102112
<table style="width:100%;">
103113
<tr><td>discarding()</td><td>Discards the response body</td></tr>
@@ -108,10 +118,20 @@ Reference https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/
108118

109119
<tr><td>ofFile(Path file)</td><td>Path with various options</td></tr>
110120
<tr><td>ofByteArrayConsumer(...)</td><td>&nbsp;</td></tr>
111-
<tr><td>fromSubscriber</td><td>various options</td></tr>
112-
<tr><td>fromLineSubscriber</td><td>various options</td></tr>
121+
<tr><td>fromSubscriber(...)</td><td>various options</td></tr>
122+
<tr><td>fromLineSubscriber(...)</td><td>various options</td></tr>
113123
</table>
114124

125+
## Overview of Request body
126+
127+
When sending body content we can use:
128+
- Object which is written as JSON content by default
129+
- byte[], String, Path (file), InputStream
130+
- formParams() for url encoded form (`application/x-www-form-urlencoded`)
131+
- Any [HttpRequest.BodyPublisher](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.BodyPublishers.html)
132+
133+
134+
115135
## Examples
116136

117137
#### GET as String
@@ -249,8 +269,8 @@ assertThat(res.statusCode()).isEqualTo(201);
249269
All async requests use JDK httpClient.sendAsync(...) returning CompletableFuture. Commonly the
250270
`whenComplete()` callback will be used to process the async responses.
251271

252-
The `bean()`, `list()` and `stream()` responses throw a `HttpException` if
253-
the status code >= 400.
272+
The `bean()`, `list()` and `stream()` responses throw a `HttpException` if the status code >= 300
273+
(noting that by default redirects are followed apart for HTTPS to HTTP).
254274

255275
<table style="width:100%;">
256276
<tr><td><b>async processing</b></td><td>&nbsp;</td></tr>

0 commit comments

Comments
 (0)