그래서 HTTPURLConnection을 사용하여 REST 서버에 연결하려고합니다. HTTPGET 요청은 content-type application/json이어야합니다. setRequestProperty("Content-Type", "application/json");
을 사용하면 값이 "text/html"로 대체되지만 setRequestProperty("Accept", "application/json");
을 사용하면 Content-Type이 application/json으로 설정됩니다. 지정시 Content-Type을 사용할 수없는 이유는 무엇입니까? 설명이 크게 감사드립니다.Android HTTPURLConnection에서 헤더를 설정할 수없는 이유는 무엇입니까?
내 현재 추측은 HTTPGET에서 "Accept"
이 작동하고 HTTPPOST에서는 "Content-Type"
입니다.
더 코드 :
connection.setRequestMethod("GET");
connection.setUseCaches(false);
//connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
중복 : http://webmasters.stackexchange.com/questions/31212/difference-between-accept-and-content-type-http-headers – ditkin