return new String(response.getContent(), encoding);
}
private static Object fetch(URL url, HTTPMethod method, Map<String, Object> options) throws IOException {
URLFetchService urlFetch = URLFetchServiceFactory.getURLFetchService();
FetchOptions fetchOptions = FetchOptions.Builder.withDefaults();
// specify the fetch options
for (Entry<String, Object> entry : options.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
switch(key) {
case "allowTruncate":
if (DefaultGroovyMethods.asBoolean(value))
fetchOptions.allowTruncate();
else
fetchOptions.disallowTruncate();
break;
case "followRedirects":
if (DefaultGroovyMethods.asBoolean(value))
fetchOptions.followRedirects();
else
fetchOptions.doNotFollowRedirects();
break;
case "deadline":
fetchOptions.setDeadline(((Number)value).doubleValue());
break;
// bypass the headers, payload, params and async options
case "headers":
case "payload":
case "params":