cant get rid of http connection
Hi All,
I am working on posting multiple request to a server using HTTPClient . First i create a HTTPConnection
(HTTPClient API: Class HTTPConnection) and then send a post request.
For every post thats made the HTTPResponse is read and processed. After i process the Response, i try to stop the
connection, but it doesn't seem to work. Although it stops when i don't play with the response. I am probably missing
some cleanup here for reponse, but there doesn't seem to be a close method for
HTTPResponse(HTTPClient API: Class HTTPResponse). This is how the
code looks ...
Code :
HTTPConnection httpCon = null;
URL myURL = new URL(url);
httpCon = new HTTPConnection(myURL);
HTTPConnection.setDefaultAllowUserInteraction(false);
httpCon.setAllowUserInteraction(false);
ArrayList<NVPair> al = new ArrayList<NVPair>();
NVPair nvp = new NVPair("Content-Type",
"application/x-www-form-urlencoded;charset=UTF-8");
al.add(nvp);
NVPair[] nvHeaderArray = (NVPair[]) al.toArray(new NVPair[] {});
httpCon.setDefaultHeaders(nvHeaderArray);
HTTPResponse response = null;
response = httpCon.Post(url, data, nvHeaderArray);
InputStream is = response.getInputStream();
is.close();
httpCon.stop();
I am not sure why the old connection doesn't die. Can anyone help me with this? Thanks everyone.
Thanks,
Kartik
Re: cant get rid of http connection
I'm not so sure you would need to close the inputstream and stop the connection. What's the actual problem you are seeing?
// Json