开发者

How to set request propert while making http connection?

i am making http connection using

URL urlToConnect = new URL ("http://www.xyz.com");
HttpURLConnection connection = ( HttpURLConnection )  urlToConnect.openConnection();

I need to set the following property ,i am doing it like

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"开发者_JS百科, "test");
connection.setRequestProperty("PASSWORD", "test");

Is it the right way to set all these data?


Yes, what you are doing is perfect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜