-
[프로그래밍] HttpURLConnection with DELETE, HEAD method2011.09.28 PM 05:45
DELETE method
// Setup connection
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("DELETE");
connection.setConnectTimeout(60 * 1000);
connection.setReadTimeout(60 * 1000);
// Send request
connection.connect();
// Read the response
int responseCode = connection.getResponseCode();
HEAD method
-- HEAD method does not returns a body you have to deal with response header
HttpURLConnection connection = ObjectDaoImpl.getConnection(path);
connection.setRequestMethod("HEAD");
connection.setConnectTimeout(60 * 1000);
connection.setReadTimeout(60 * 1000);
// Send request
connection.connect();
// Read the response
int responseCode = connection.getResponseCode();
댓글 : 1 개
- 뎐이닷
- 2011/09/28 PM 06:00
java network 이네요 : )
user error : Error. B.