简体   繁体   中英

HttpURLConnection, openConnection and setRequestMethod(“GET”

I am currently trying to understand the logic behind each of the code below. Please let me know if I am correct and answer my confusions.

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

This question is not related to Java at all. What you need is to understand HTTP protocol and do some comprehensive reading. I recommend starting with

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

and then read:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM