Adding a comment if you have a long connection and you send GET and POST, this is what I do:
if (doGet) { // some boolean con.setDoOutput(false); // reset any previous setting, if con is long lasting con.setRequestMethod("GET"); } else { con.setDoOutput(true); // reset any previous setting, if con is long lasting con.setRequestMethod("POST"); }
To avoid a long connection, close it each time.
if (doClose) // some boolean con.setRequestProperty("Connection", "close"); con.connect(); // force connect request
SoloPilot Feb 10 '16 at 15:44 2016-02-10 15:44
source share