Lydia
Lydia

Reputation: 625

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

Upvotes: 0

Views: 346

Answers (1)

Michal Wilkowski
Michal Wilkowski

Reputation: 747

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:

https://www.rfc-editor.org/rfc/rfc7230

Upvotes: 1

Related Questions