|
| Home > Apache Geronimo Development > Index > AsyncHttpClient |
AsyncHttpClient client = new AsyncHttpClient();
Once you have the client created, the client is used to request content from different URLs:
HttpRequestMessage request = new HttpRequestMessage(url, callback);client.sendRequest(request);
That's all there is to send a request. The callback argument is an object that implements the AsyncHttpClientCallback interface. The callback handler will be notified of successful completion of the request and given the returned response. The callback will also be notified of connection closings, request timeouts, or any other request failure situation.
A single client instance can process multiple requests at one time and can be reused after requests complete. If it is anticipated that multiple requests will be made from target servers that support keep alive connections, a SessionCache can be used with the AHC client to allow live connections to be reused.
sessionCache = new SessionCache(); // enable connection reuse client.setSessionCache(sessionCache);
* javadoc
|
|
Privacy Policy - Copyright © 2003-2011, The Apache Software Foundation, Licensed under ASL 2.0. |