What is the function or purpose of HttpURLConnection.setDoInput
and HttpURLConnection.setDoOutput
?
I was still confused as to what exactly was meant in the documentation by "Use the url connection for input".
That could mean that you want read information from the response or that you want to input information into its request. The documentation states:
A URL connection can be used for input and/or output. Setting the doInput flag to true indicates that the application intends to read data from the URL connection.
The default value of this field is true.
So if you want to ignore data from the response then you can set doInput to false. If you want to use getInputStream() then you should leave this alone or set it to true.
A URL connection can be used for input and/or output. Setting the doOutput flag to true indicates that the application intends to write data to the URL connection.
The default value of this field is false.
So if you want append data to the request (calling getOutputStream()) then you must set doOutput to true.