Skip to content

Commit 3341a30

Browse files
author
Oleksandr Kylymnychenko
committed
Merge remote-tracking branch 'upstream/master'
2 parents f35c878 + f4b71aa commit 3341a30

File tree

514 files changed

+20438
-26182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+20438
-26182
lines changed

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Async Http Client library purpose is to allow Java applications to easily execut
1010
<dependency>
1111
<groupId>com.ning</groupId>
1212
<artifactId>async-http-client</artifactId>
13-
<version>1.7.16</version>
13+
<version>1.8.13</version>
1414
</dependency>
1515
```
1616

1717
You can also download the artifact
1818

1919
[Maven Search](http://search.maven.org)
2020

21-
Then in your code you can simply do ([Javadoc](http://sonatype.github.com/async-http-client/apidocs/index.html))
21+
Then in your code you can simply do [Javadoc](http://asynchttpclient.github.io/async-http-client/apidocs/reference/packages.html)
2222

2323
```java
2424
import com.ning.http.client.*;
@@ -133,14 +133,18 @@ Future<String> f = c.prepareGet("http://www.ning.com/").execute(new AsyncHandler
133133
String bodyResponse = f.get();
134134
```
135135

136-
Finally, you can also configure the AsyncHttpClient via it's AsyncHttpClientConfig object:
136+
## Configuration
137+
138+
Finally, you can also configure the AsyncHttpClient via its AsyncHttpClientConfig object:
137139

138140
```java
139141
AsyncHttpClientConfig cf = new AsyncHttpClientConfig.Builder()
140142
S.setProxyServer(new ProxyServer("127.0.0.1", 38080)).build();
141143
AsyncHttpClient c = new AsyncHttpClient(cf);
142144
```
143145

146+
## WebSocket
147+
144148
Async Http Client also support WebSocket by simply doing:
145149

146150
```java
@@ -154,7 +158,7 @@ WebSocket websocket = c.prepareGet(getTargetUrl())
154158

155159
@Override
156160
public void onOpen(WebSocket websocket) {
157-
websocket.sendTextMessage("...").sendBinaryMessage("...");
161+
websocket.sendTextMessage("...").sendMessage("...");
158162
}
159163

160164
@Override
@@ -175,10 +179,29 @@ AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder().build();
175179
AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config);
176180
```
177181

182+
## User Group
183+
178184
Keep up to date on the library development by joining the Asynchronous HTTP Client discussion group
179185

180186
[Google Group](http://groups.google.com/group/asynchttpclient)
181187

182188
or follow us on [Twitter](http://twitter.com/jfarcand)
183189

184190
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/6433679063b2351599c6ca44a08246a2 "githalytics.com")](http://githalytics.com/AsyncHttpClient/async-http-client)
191+
192+
## Contributing
193+
194+
Of course, Pull Requests are welcome.
195+
196+
Here a the few rules we'd like you to respect if you do so:
197+
198+
* Only edit the code related to the suggested change, so DON'T automatically format the classes you've edited.
199+
* Respect the formatting rules:
200+
* Ident with 4 spaces
201+
* Use a 140 chars line max length
202+
* Don't use * imports
203+
* Stick to the org, com, javax, java imports order
204+
* Your PR can contain multiple commits when submitting, but once it's been reviewed, we'll ask you to squash them into a single one
205+
* Regarding licensing:
206+
* You must be the original author of the code you suggest.
207+
* If not, you have to prove that the original code was published under Apache License 2 and properly mention original copyrights.

api/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@
3131
</build>
3232

3333
<dependencies>
34+
<dependency>
35+
<groupId>com.typesafe</groupId>
36+
<artifactId>config</artifactId>
37+
<version>1.2.1</version>
38+
</dependency>
3439
<dependency>
3540
<groupId>org.slf4j</groupId>
3641
<artifactId>slf4j-api</artifactId>
37-
<version>1.7.5</version>
42+
<version>1.7.6</version>
3843
</dependency>
3944
</dependencies>
4045

api/src/main/java/org/asynchttpclient/AsyncCompletionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public STATE onContentWriteCompleted() {
105105
/**
106106
* Invoked when the I/O operation associated with the {@link Request} body as been progressed.
107107
*
108-
* @param amount The amount of bytes to transfer.
108+
* @param amount The amount of bytes to transfer
109109
* @param current The amount of bytes transferred
110110
* @param total The total number of bytes transferred
111111
* @return a {@link org.asynchttpclient.AsyncHandler.STATE} telling to CONTINUE or ABORT the current processing.

api/src/main/java/org/asynchttpclient/AsyncCompletionHandlerBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Response onCompleted(Response response) throws Exception {
3636
/**
3737
* {@inheritDoc}
3838
*/
39-
/* @Override */
39+
@Override
4040
public void onThrowable(Throwable t) {
4141
log.debug(t.getMessage(), t);
4242
}

api/src/main/java/org/asynchttpclient/AsyncHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public static enum STATE {
7070

7171
/**
7272
* Invoked as soon as some response body part are received. Could be invoked many times.
73+
* Beware that, depending on the provider (Netty) this can be notified with empty body parts.
7374
*
7475
* @param bodyPart response's body part.
7576
* @return a {@link STATE} telling to CONTINUE or ABORT the current processing.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2010-2012 Sonatype, Inc. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7+
*
8+
* Unless required by applicable law or agreed to in writing,
9+
* software distributed under the Apache License Version 2.0 is distributed on an
10+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12+
*/
13+
package org.asynchttpclient;
14+
15+
/**
16+
* This interface hosts new low level callback methods on {@link AsyncHandler}.
17+
* For now, those methods are in a dedicated interface in order not to break the existing API,
18+
* but could be merged into one of the existing ones in AHC 2.
19+
*
20+
* More additional hooks might come, such as:
21+
* <ul>
22+
* <li>onConnectionClosed()</li>
23+
* <li>onBytesSent(long numberOfBytes)</li>
24+
* <li>onBytesReceived(long numberOfBytes)</li>
25+
* </ul>
26+
*/
27+
public interface AsyncHandlerExtensions {
28+
29+
/**
30+
* Notify the callback when trying to open a new connection.
31+
*/
32+
void onOpenConnection();
33+
34+
/**
35+
* Notify the callback when a new connection was successfully opened.
36+
*/
37+
void onConnectionOpen();
38+
39+
/**
40+
* Notify the callback when trying to fetch a connection from the pool.
41+
*/
42+
void onPoolConnection();
43+
44+
/**
45+
* Notify the callback when a new connection was successfully fetched from the pool.
46+
*/
47+
void onConnectionPooled();
48+
49+
/**
50+
* Notify the callback when a request is being written on the wire.
51+
* If the original request causes multiple requests to be sent, for example, because of authorization or retry,
52+
* it will be notified multiple times.
53+
*/
54+
void onSendRequest();
55+
56+
/**
57+
* Notify the callback every time a request is being retried.
58+
*/
59+
void onRetry();
60+
}

0 commit comments

Comments
 (0)