java - Apache Client 4.x close a HttpRequestBase -


i trying create method called close() when called release connection httprequestbase have called httpmethod. issue code below have worked fine in client 3.x doesn't work android api 21 uses version of client 4.x question how close connection

public void close() {     executorservice es =(executorservice) callablesingleton.getexecutor();     es.shutdown();     if (null != httpmethod) {         httpmethod.releaseconnection();         //postmethod.abort();     }     httpmethod = null; } 

i guess this:

try{   closeablehttpresponse response = httpclient.execute(target, http_req, localcontext);   response.getentity().writeto(system.out);   // read entire stream end in order reuse connection   entityutils.consume(response.getentity()); }finally{    response.close(); } 

when http client no longer need can execute httpclient.close(); terminates open connections. client 4.x quite different client 3.x, guess need more refactoring.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -