I'm trying to set a connection timeout with Groovy HTTPBuilder and for the life of me can't find a way.
Using plain ol' URL it's easy:
def client = new URL("https://search.yahoo.com/search?q=foobar") def result = client.getText( readTimeout: 1 ) This throws a SocketTimeoutException, but that's not quite what I want. For a variety of reasons, I'd rather use HTTPBuilder or better RESTClient.
This does work:
def client = new HTTPBuilder() def result = client.request("https://search.yahoo.com/", Method.GET, "*/*") { HttpRequest request -> uri.path = "search" uri.query = [q: "foobar"] request.getParams().setParameter("http.socket.timeout", 1); } However request.getParams() has been deprecated.
For the life of me I can't find a way to inject a proper RequestConfig into the builder.
client.client.params.setParameter("http.socket.timeout", 1000)