• [프로그래밍] HttpURLConnection with DELETE, HEAD method2011.09.28 PM 05:45

게시물 주소 FONT글자 작게하기 글자 키우기

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 개
java network 이네요 : )
친구글 비밀글 댓글 쓰기