i'm connecting application rest type webservice. i'm using apache http library, request standard post request, ran in background thread.
now problem if i'm using
http://myserver.com/api/command
it works , proper response, same url https:
https://myserver.com/api/command
i empty response. http header 200 ok.
both of these work on 2.0.3 not on 4.0.3. on 4.0.3 api seems work if use plain http, https empty responses.
this code:
@override protected httpresponse doinbackground(string... params) { string link = params[0]; httpclient client = createhttpclient(); try { hashmap<string, contentbody> files = apimanager.getfiles(); multipartentity mpentity = new multipartentity(); if(files != null) { for(string : files.keyset()) { contentbody k = files.get(i); mpentity.addpart(i, k); } } if(this.callparameters != null) { for(namevaluepair : this.callparameters) { stringbody sb = new stringbody((string)i.getvalue(),"text/plain",charset.forname("utf-8")); mpentity.addpart(i.getname(), sb); } } httppost.setentity(mpentity); // execute http post request log.d("apitask","executing request: "+httppost.getrequestline()); httpresponse response = null; response = client.execute(httppost); client.getconnectionmanager().shutdown(); return response; } catch(unknownhostexception e) { exception = e; return null; } catch (ioexception e) { exception = e; return null; } catch(exception e) { return null; } } @override protected void onpostexecute(httpresponse result) { system.out.println("status:"+result.getstatusline()); try { stringbuilder responsetext = this.inputstreamtostring(result.getentity().getcontent()); system.out.println("response:"+responsetext); } catch(exception e) { system.out.println("error"); } } private httpclient createhttpclient() { httpparams params = new basichttpparams(); httpprotocolparams.setversion(params, httpversion.http_1_1); httpprotocolparams.setcontentcharset(params, http.default_content_charset); httpprotocolparams.setuseexpectcontinue(params, true); httpconnectionparams.setconnectiontimeout(params, 10000); httpconnectionparams.setsotimeout(params, 10000); schemeregistry schreg = new schemeregistry(); schreg.register(new scheme("http", plainsocketfactory.getsocketfactory(), 80)); schreg.register(new scheme("https", sslsocketfactory.getsocketfactory(), 443)); clientconnectionmanager conmgr = new threadsafeclientconnmanager(params, schreg); return new defaulthttpclient(conmgr, params); }
thank in advance
Comments
Post a Comment