The method disconnect from HttpURLConnection seems not to work properly. If I execute the 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 ();
// Some code
connection.disconnect ();
connection.setDoInput(false); // -> IllegalStateException
I get an IllegalStateException
when I call the method setDoInput
. The exception says: "Already connected"