HttpURLConnection disconnect doesn't work in Android -


the method disconnect httpurlconnection seems not work properly. if execute following code:

url = new url("http:// ..."); connection = (httpurlconnection) url.openconnection (); connection.setrequestmethod("post"); connection.setrequestproperty("content-type", "application/x-www-form-urlencoded"); connection.setusecaches(false); connection.setdoinput(true); connection.setdooutput(true); connection.connect(); // code connection.disconnect(); connection.setdoinput(false); // -> illegalstateexception 

i illegalstateexception when call method setdoinput. exception says:

already connected

it sounds you're trying reuse connection? i.e. altering request properties after you've disconnected server, ready make connection.

if case, create new httpurlconnection object.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -