Skip to content

Commit 2b232a4

Browse files
n-milesslandelle
authored andcommitted
Docs fixes/clarity improvements (#1594)
Thanks a lo, it really helps!
1 parent 1281264 commit 2b232a4

File tree

7 files changed

+37
-36
lines changed

7 files changed

+37
-36
lines changed

Diff for: README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Follow [@AsyncHttpClient](https://twitter.com/AsyncHttpClient) on Twitter.
55
The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and asynchronously process HTTP responses.
66
The library also supports the WebSocket Protocol.
77

8-
It's built on top of [Netty](https://github.com/netty/netty). I's currently compiled on Java 8 but runs on Java 9 too.
8+
It's built on top of [Netty](https://github.com/netty/netty). It's currently compiled on Java 8 but runs on Java 9 too.
99

1010
## Installation
1111

@@ -159,7 +159,7 @@ See `AsyncCompletionHandler` implementation as an example.
159159

160160
The below sample just capture the response status and skips processing the response body chunks.
161161

162-
Note that returning `ABORT` closed the underlying connection.
162+
Note that returning `ABORT` closes the underlying connection.
163163

164164
```java
165165
import static org.asynchttpclient.Dsl.*;
@@ -196,7 +196,7 @@ Integer statusCode = whenStatusCode.get();
196196

197197
#### Using Continuations
198198

199-
`ListenableFuture` has a `toCompletableFuture` that returns a `CompletableFuture`.
199+
`ListenableFuture` has a `toCompletableFuture` method that returns a `CompletableFuture`.
200200
Beware that canceling this `CompletableFuture` won't properly cancel the ongoing request.
201201
There's a very good chance we'll return a `CompletionStage` instead in the next release.
202202

@@ -244,7 +244,7 @@ WebSocket websocket = c.prepareGet("ws://demos.kaazing.com/echo")
244244

245245
## Reactive Streams
246246

247-
AsyncHttpClient has build in support for reactive streams.
247+
AsyncHttpClient has built-in support for reactive streams.
248248

249249
You can pass a request body as a `Publisher<ByteBuf>` or a `ReactiveStreamsBodyGenerator`.
250250

@@ -289,7 +289,7 @@ Keep up to date on the library development by joining the Asynchronous HTTP Clie
289289

290290
Of course, Pull Requests are welcome.
291291

292-
Here a the few rules we'd like you to respect if you do so:
292+
Here are the few rules we'd like you to respect if you do so:
293293

294294
* Only edit the code related to the suggested change, so DON'T automatically format the classes you've edited.
295295
* Use IntelliJ default formatting rules.

Diff for: client/src/main/java/org/asynchttpclient/AsyncCompletionHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* An {@link AsyncHandler} augmented with an {@link #onCompleted(Response)}
2626
* convenience method which gets called when the {@link Response} processing is
27-
* finished. This class also implement the {@link ProgressAsyncHandler}
27+
* finished. This class also implements the {@link ProgressAsyncHandler}
2828
* callback, all doing nothing except returning
2929
* {@link org.asynchttpclient.AsyncHandler.State#CONTINUE}
3030
*

Diff for: client/src/main/java/org/asynchttpclient/AsyncHandler.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
* </ol>
3838
* <br>
3939
* Returning a {@link AsyncHandler.State#ABORT} from any of those callback methods will interrupt asynchronous response
40-
* processing, after that only {@link #onCompleted()} is going to be called.
40+
* processing. After that, only {@link #onCompleted()} is going to be called.
4141
* <br>
42-
* AsyncHandler aren't thread safe, hence you should avoid re-using the same instance when doing concurrent requests.
42+
* AsyncHandlers aren't thread safe. Hence, you should avoid re-using the same instance when doing concurrent requests.
4343
* As an example, the following may produce unexpected results:
4444
* <blockquote><pre>
4545
* AsyncHandler ah = new AsyncHandler() {....};
@@ -49,9 +49,10 @@
4949
* </pre></blockquote>
5050
* It is recommended to create a new instance instead.
5151
* <p>
52-
* Do NOT perform any blocking operation in there, typically trying to send another request and call get() on its future.
52+
* Do NOT perform any blocking operations in any of these methods. A typical example would be trying to send another
53+
* request and calling get() on its future.
5354
* There's a chance you might end up in a dead lock.
54-
* If you really to perform blocking operation, executed it in a different dedicated thread pool.
55+
* If you really need to perform a blocking operation, execute it in a different dedicated thread pool.
5556
*
5657
* @param <T> Type of object returned by the {@link java.util.concurrent.Future#get}
5758
*/
@@ -142,6 +143,8 @@ default void onHostnameResolutionSuccess(String name, List<InetSocketAddress> ad
142143
default void onHostnameResolutionFailure(String name, Throwable cause) {
143144
}
144145

146+
// ////////////// TCP CONNECT ////////
147+
145148
/**
146149
* Notify the callback when trying to open a new connection.
147150
* <p>
@@ -152,8 +155,6 @@ default void onHostnameResolutionFailure(String name, Throwable cause) {
152155
default void onTcpConnectAttempt(InetSocketAddress remoteAddress) {
153156
}
154157

155-
// ////////////// TCP CONNECT ////////
156-
157158
/**
158159
* Notify the callback after a successful connect
159160
*
@@ -174,14 +175,14 @@ default void onTcpConnectSuccess(InetSocketAddress remoteAddress, Channel connec
174175
default void onTcpConnectFailure(InetSocketAddress remoteAddress, Throwable cause) {
175176
}
176177

178+
// ////////////// TLS ///////////////
179+
177180
/**
178181
* Notify the callback before TLS handshake
179182
*/
180183
default void onTlsHandshakeAttempt() {
181184
}
182185

183-
// ////////////// TLS ///////////////
184-
185186
/**
186187
* Notify the callback after the TLS was successful
187188
*/
@@ -196,14 +197,14 @@ default void onTlsHandshakeSuccess() {
196197
default void onTlsHandshakeFailure(Throwable cause) {
197198
}
198199

200+
// /////////// POOLING /////////////
201+
199202
/**
200203
* Notify the callback when trying to fetch a connection from the pool.
201204
*/
202205
default void onConnectionPoolAttempt() {
203206
}
204207

205-
// /////////// POOLING /////////////
206-
207208
/**
208209
* Notify the callback when a new connection was successfully fetched from the pool.
209210
*
@@ -220,6 +221,8 @@ default void onConnectionPooled(Channel connection) {
220221
default void onConnectionOffer(Channel connection) {
221222
}
222223

224+
// //////////// SENDING //////////////
225+
223226
/**
224227
* Notify the callback when a request is being written on the channel. If the original request causes multiple requests to be sent, for example, because of authorization or
225228
* retry, it will be notified multiple times.
@@ -229,8 +232,6 @@ default void onConnectionOffer(Channel connection) {
229232
default void onRequestSend(NettyRequest request) {
230233
}
231234

232-
// //////////// SENDING //////////////
233-
234235
/**
235236
* Notify the callback every time a request is being retried.
236237
*/

Diff for: client/src/main/java/org/asynchttpclient/AsyncHttpClient.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
import java.util.function.Predicate;
2222

2323
/**
24-
* This class support asynchronous and synchronous HTTP request.
24+
* This class support asynchronous and synchronous HTTP requests.
2525
* <br>
26-
* To execute synchronous HTTP request, you just need to do
26+
* To execute a synchronous HTTP request, you just need to do
2727
* <blockquote><pre>
2828
* AsyncHttpClient c = new AsyncHttpClient();
2929
* Future&lt;Response&gt; f = c.prepareGet(TARGET_URL).execute();
3030
* </pre></blockquote>
3131
* <br>
32-
* The code above will block until the response is fully received. To execute asynchronous HTTP request, you
32+
* The code above will block until the response is fully received. To execute an asynchronous HTTP request, you
3333
* create an {@link AsyncHandler} or its abstract implementation, {@link AsyncCompletionHandler}
3434
* <br>
3535
* <blockquote><pre>
@@ -48,7 +48,7 @@
4848
* &#125;);
4949
* Response response = f.get();
5050
*
51-
* // We are just interested to retrieve the status code.
51+
* // We are just interested in retrieving the status code.
5252
* Future&lt;Integer&gt; f = c.prepareGet(TARGET_URL).execute(new AsyncCompletionHandler&lt;Integer&gt;() &#123;
5353
*
5454
* &#64;Override
@@ -63,10 +63,10 @@
6363
* &#125;);
6464
* Integer statusCode = f.get();
6565
* </pre></blockquote>
66-
* The {@link AsyncCompletionHandler#onCompleted(Response)} will be invoked once the http response has been fully read, which include
67-
* the http headers and the response body. Note that the entire response will be buffered in memory.
66+
* The {@link AsyncCompletionHandler#onCompleted(Response)} method will be invoked once the http response has been fully read.
67+
* The {@link Response} object includes the http headers and the response body. Note that the entire response will be buffered in memory.
6868
* <br>
69-
* You can also have more control about the how the response is asynchronously processed by using a {@link AsyncHandler}
69+
* You can also have more control about the how the response is asynchronously processed by using an {@link AsyncHandler}
7070
* <blockquote><pre>
7171
* AsyncHttpClient c = new AsyncHttpClient();
7272
* Future&lt;String&gt; f = c.prepareGet(TARGET_URL).execute(new AsyncHandler&lt;String&gt;() &#123;
@@ -106,8 +106,8 @@
106106
*
107107
* String bodyResponse = f.get();
108108
* </pre></blockquote>
109-
* You can asynchronously process the response status,headers and body and decide when to
110-
* stop the processing the response by returning a new {@link AsyncHandler.State#ABORT} at any moment.
109+
* You can asynchronously process the response status, headers and body and decide when to
110+
* stop processing the response by returning a new {@link AsyncHandler.State#ABORT} at any moment.
111111
*
112112
* This class can also be used without the need of {@link AsyncHandler}.
113113
* <br>
@@ -125,8 +125,8 @@
125125
* Response r = f.get();
126126
* </pre></blockquote>
127127
* <br>
128-
* An instance of this class will cache every HTTP 1.1 connections and close them when the {@link DefaultAsyncHttpClientConfig#getReadTimeout()}
129-
* expires. This object can hold many persistent connections to different host.
128+
* An instance of this class will cache every HTTP 1.1 connection and close them when the {@link DefaultAsyncHttpClientConfig#getReadTimeout()}
129+
* expires. This object can hold many persistent connections to different hosts.
130130
*/
131131
public interface AsyncHttpClient extends Closeable {
132132

@@ -138,7 +138,7 @@ public interface AsyncHttpClient extends Closeable {
138138
boolean isClosed();
139139

140140
/**
141-
* Set default signature calculator to use for requests build by this client instance
141+
* Set default signature calculator to use for requests built by this client instance
142142
*
143143
* @param signatureCalculator a signature calculator
144144
* @return {@link RequestBuilder}

Diff for: client/src/main/java/org/asynchttpclient/RequestBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import static org.asynchttpclient.util.HttpConstants.Methods.GET;
1919

2020
/**
21-
* Builder for a {@link Request}. Warning: mutable and not thread-safe! Beware that it holds a reference on the Request instance it builds, so modifying the builder will modify the
21+
* Builder for a {@link Request}. Warning: mutable and not thread-safe! Beware that it holds a reference to the Request instance it builds, so modifying the builder will modify the
2222
* request even after it has been built.
2323
*/
2424
public class RequestBuilder extends RequestBuilderBase<RequestBuilder> {

Diff for: client/src/main/java/org/asynchttpclient/Response.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@ public interface Response {
160160
boolean hasResponseBody();
161161

162162
/**
163-
* Get remote address client initiated request to.
163+
* Get the remote address that the client initiated the request to.
164164
*
165-
* @return remote address client initiated request to, may be {@code null} if asynchronous provider is unable to provide the remote address
165+
* @return The remote address that the client initiated the request to. May be {@code null} if asynchronous provider is unable to provide the remote address
166166
*/
167167
SocketAddress getRemoteAddress();
168168

169169
/**
170-
* Get local address client initiated request from.
170+
* Get the local address that the client initiated the request from.
171171
*
172-
* @return local address client initiated request from, may be {@code null} if asynchronous provider is unable to provide the local address
172+
* @return The local address that the client initiated the request from. May be {@code null} if asynchronous provider is unable to provide the local address
173173
*/
174174
SocketAddress getLocalAddress();
175175

Diff for: client/src/main/java/org/asynchttpclient/SslEngineFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public interface SslEngineFactory {
2020

2121
/**
22-
* Creates new {@link SSLEngine}.
22+
* Creates a new {@link SSLEngine}.
2323
*
2424
* @param config the client config
2525
* @param peerHost the peer hostname

0 commit comments

Comments
 (0)