Skip to content

Commit

Permalink
Implementation of really PUT and POST HTTP methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanouse authored and stuartwdouglas committed Sep 6, 2011
1 parent 714fe05 commit 21373ce
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ public String call() throws Exception {
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("PUT");
final OutputStream out = conn.getOutputStream();
try {
write(out, message);
return processResponse(conn);
}
finally {
out.close();
}
}
};
return execute(task, timeout, unit);
}

public static String post(final String spec, final String message, final long timeout, final TimeUnit unit) throws MalformedURLException, ExecutionException, TimeoutException {
final URL url = new URL(spec);
Callable<String> task = new Callable<String>() {
@Override
public String call() throws Exception {
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
final OutputStream out = conn.getOutputStream();
try {
write(out, message);
Expand Down

0 comments on commit 21373ce

Please sign in to comment.