Android BufferedInputStream HTTP POST/GET -


i use bufferedinputstream http post/get

but error below

  1. java.io.filenotfoundexception: http://xx.xx.xx.xx/webws/data.aspx
  2. transport endpoint not connected

why error. code below

url url = new url(glob.posturl);      httpurlconnection httpconn = (httpurlconnection) url.openconnection();      try {          httpconn.setdoinput(true);         httpconn.setdooutput(true);         httpconn.setrequestmethod("get");         httpconn.setrequestproperty("content-type",                 "application/x-www-form-urlencoded");         httpconn.setrequestproperty("content-language", "tr");               httpconn.setconnecttimeout(12000);           iterator<string> reqprops = hmap.keyset().iterator();         while (reqprops.hasnext()) {             string key = reqprops.next();             string value = hmap.get(key);             httpconn.addrequestproperty(key, value);         }          inputstream in = new bufferedinputstream(httpconn.getinputstream());          stringbuilder builder = new stringbuilder();         string line;         try {             bufferedreader reader = new bufferedreader(                     new inputstreamreader(in, "utf-8"));             while ((line = reader.readline()) != null) {                 builder.append(line);             }         } {             in.close();         }         httpconn.disconnect(); 

thanks.

is there reason you're not using httpclient?

you can replace code like:

httpcontext httpcontext = new basichttpcontext(); httpclient httpclient = new defaulthttpclient(); httpget httpget = new httpget(url); httpresponse response = httpclient.execute(httpget, httpcontext); int statuscode = response.getstatusline().getstatuscode(); httpentity entity = response.getentity(); string page = entityutils.tostring(entity); 

you can setup httpclient clientconnectionmanager , httpparams security , various http parameters client @ initialisation (plenty of examples around if search on class names).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -