我正在使用
进行http连接URL urlToConnect = new URL ("http://www.xyz.com");
HttpURLConnection connection = ( HttpURLConnection ) urlToConnect.openConnection();
我需要设置以下属性,我就像
一样connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("user-agent", USER_AGENT);
connection.setRequestProperty("Content-Type", "application/xml");
connection.setRequestProperty("Accept", "application/xml");
connection.setRequestProperty("http_code", "200");
connection.setRequestProperty("USERNAME", "test");
connection.setRequestProperty("PASSWORD", "test");
这是设置所有这些数据的正确方法吗?
答案 0 :(得分:1)
是的,你在做什么是完美的。