ArchTiger MYPI

ArchTiger
접속 : 3075   Lv. 51

Category

Profile

Counter

  • 오늘 : 4 명
  • 전체 : 10870 명
  • Mypi Ver. 0.3.1 β
[프로그래밍] HttpURLConnection with DELETE, HEAD method (1) 2011/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();

신고

 

뎐이닷    친구신청

java network 이네요 : )
X