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
+17-8Lines changed: 17 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,9 @@ Then in your code you can simply do ([Javadoc](http://sonatype.github.com/async-
29
29
Response r = f.get();
30
30
```
31
31
32
-
You can also accomplish asynchronous operation without using a Future if you want to receive and process the response in your handler:
32
+
Note that in this case all the content must be read fully in memory, even if you used `getResponseBodyAsStream()' method on returned `Response` object.
33
+
34
+
You can also accomplish asynchronous (non-blocking) operation without using a Future if you want to receive and process the response in your handler:
33
35
34
36
```java
35
37
importcom.ning.http.client.*;
@@ -52,6 +54,8 @@ You can also accomplish asynchronous operation without using a Future if you wan
52
54
});
53
55
```
54
56
57
+
(this will also fully read `Response` in memory before calling `onCompleted`)
58
+
55
59
You can also mix Future with AsyncHandler to only retrieve part of the asynchronous response
56
60
57
61
```java
@@ -74,9 +78,11 @@ You can also mix Future with AsyncHandler to only retrieve part of the asynchron
74
78
}
75
79
});
76
80
77
-
intstatuѕCode= f.get();
81
+
intstatusCode= f.get();
78
82
```
79
83
84
+
which is something you want to do for large responses: this way you can process content as soon as it becomes available, piece by piece, without having to buffer it all in memory.
85
+
80
86
You have full control on the Response life cycle, so you can decide at any moment to stop processing what the server is sending back:
81
87
82
88
```java
@@ -85,14 +91,16 @@ You can also mix Future with AsyncHandler to only retrieve part of the asynchron
85
91
86
92
AsyncHttpClient c =newAsyncHttpClient();
87
93
Future<String> f = c.prepareGet("http://www.ning.com/ ").execute(newAsyncHandler<String>() {
0 commit comments