Use the setBody method to add a body to the request. import org.asynchttpclient.* įuture whenResponse=asyncHttpClient.prepareGet("").execute() įuture whenResponse=asyncHttpClient.executeRequest(request) You'll then be responsible for closingįinally, you can also configure the AsyncHttpClient instance via its AsyncHttpClientConfig object: import static .* ĪsyncHttpClient c=asyncHttpClient(config().setProxyServer(proxyServer("127.0.0.1",38080))) ĪHC provides 2 APIs for defining requests: bound and unbound.ĪsyncHttpClient and Dsl` provide methods for standard HTTP methods (POST, PUT, etc) but you can also pass a custom one. It's possible to create shared resources (EventLoop and Timer) beforehand and pass them to multiple client instances in the config. Typically, AHC will usually underperform if you create a new client for each request, as it will create new threads and connection pools for each. If you don't, you'll experience threads hanging and resource leaks.ĪsyncHttpClient instances are intended to be global resources that share the same lifecycle as the application. Import the Dsl helpers to use convenient methods to bootstrap components: import static .* Ĭlient import static .* ĪsyncHttpClient asyncHttpClient=asyncHttpClient() ĪsyncHttpClient instances must be closed (call the close method) once you're done with them, typically when shutting down your application. Basicsįeel free to check the Javadoc or the code for more information.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |