HttpURLConnection,openConnection和setRequestMethod(" GET"

时间:2014-12-20 22:08:40

标签: java android httpurlconnection

我目前正在尝试理解下面每个代码背后的逻辑。如果我是正确的,请告诉我并回答我的困惑。

urlConnection = (HttpURLConnection) url.openConnection(); 
//connection object is created. However, do not understand 
//"manipulate parameters that affect the connection to the remote resource."
urlConnection.setRequestMethod("GET");
//set the method for the URL request. Not sure what that means! 
//there are other strings that could be used, but not sure what each means, 
//and couldn't the Java documentations didn't seem to have explanations either
urlConnection.connect();
//the actual connection the the remote object is made

1 个答案:

答案 0 :(得分:1)

这个问题根本与Java无关。您需要的是了解HTTP协议并进行全面的阅读。我建议从

开始

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

然后阅读:

http://tools.ietf.org/html/rfc7230