android
HttpClient - Android 6.0 에서 삭제됨. - HttpURLConnection 사용.
도마_
2015. 11. 23. 10:39
HttpClient 가 android 6.0 에서 삭제 되었다.
build.gradle 에
android {
useLibrary 'org.apache.http.legacy'
}
를 추가 한뒤에 사용하던지 - deprecated 된 상태로 나온다. - 가로줄 쳐짐.
HttpURLConnection 을 대신 사용 하도록 한다.
URL url = new URL("http://some-server");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
// read the response
System.out.println("Response Code: " + conn.getResponseCode());
InputStream in = new BufferedInputStream(conn.getInputStream());
String response = org.apache.commons.io.IOUtils.toString(in, "UTF-8");
System.out.println(response);