AsyncHTTPBuilder is very similar to HTTPBuilder, except that all requests are delegated to a thread pool and executed asynchronously. Requests return a java.util.concurrent.Future instance, which can be used to access the response data once it has completed.

import static

def http = new AsyncHTTPBuilder(
                poolSize : 4,
                uri : '',
                contentType : HTML )

def result = http.get(path:'/') { resp, html ->
    println ' got async response!'
    return html

assert result instanceof java.util.concurrent.Future

while ( ! result.done ) {
    println 'waiting...'

/* The Future instance contains whatever is returned from the response
   closure above; in this case the parsed HTML data: */
def html = result.get()
assert html instanceof groovy.util.slurpersupport.GPathResult

In practice, it is very similar to the Ajax.Request class in Prototype.js.

This class also demonstrates the ease of which HTTPBuilder can be extended. The doRequest() method was simply overridden in order to execute requests from a ThreadPoolExecutor. You can see the full source code here.