I want to change Content-Type but it dose not work…right?
code:
HttpURLConnection conn=(HttpURLConnection)url.openConnection();
conn.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
System.out.println(conn.getContentType());
the output is not “text/plain; charset=utf-8″…anything wrong?
Thanks
The value of
getContentType()returns the value of theContent-Typeheader from the response, not the value set on the request. See the Javadoc I linked to. What exactly are you trying to do?