Skip to content

Instantly share code, notes, and snippets.

@tinoviena
tinoviena / gist:2893779
Created June 8, 2012 05:33
Groovy script to make HTTP request using Java standard library.
URL url = new URL(urlTarget);
HttpURLConnection connection;
method = "GET" // POST, PUT, ...
data = "" // for GET, otherwise e..g JSON
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod(method);
connection.setRequestProperty("Content-Length", "" + Integer.toString(data.getBytes().length));