Android :- Problem in getting response from a https request ,the second time the request is posted -
i'm trying data web service https://..... problem proper response first time request made if request made there no response. log shows once "freeing openssl session".
here postonserver code.
public static string postdataonserver(string getrequest) throws ioexception { log.e("request : ", getrequest); try { url url = null; httpurlconnection con = null; try { url = new url(getrequest); con = (httpurlconnection) url.openconnection(); con.setrequestmethod("get"); con.setusecaches(false); con.setdooutput(true); con.setdoinput(true); con.setrequestproperty("user-agent", "test-ssl"); con.setrequestproperty("connection", "close"); con.connect(); } catch (ioexception e) { log.e("ioexception : ", e.tostring()); return "connection not established"; } bufferedreader in = new bufferedreader(new inputstreamreader(con .getinputstream())); stringbuffer res = new stringbuffer(); char[] chbuff = new char[1000]; int len = 0; while ((len = in.read(chbuff)) > 0) res.append(new string(chbuff, 0, len)); in.close(); system.gc(); log.e("responce :" , res.tostring()); return res.tostring(); } catch (sockettimeoutexception e) { log.e("responce :" , e.tostring()); }catch (exception e) { } return ""; }
plz reply ,thank
Comments
Post a Comment