这个问题已经在这里有了答案: > How to set content-length in android? 1个
我已经设置了几乎所有数据:
String capcha = editText.getText().toString();httpClIEnt httpclIEnt = new DefaulthttpClIEnt();httpPost httppost = new httpPost("myurl.asp");// Add your data String str = "param1=x¶m2=y";StringEntity strEntity = new StringEntity(str);httppost.setEntity(strEntity);httppost.setheader("Set-cookie", sessioncookie);httppost.setheader("Accept", "text/HTML");httppost.setheader("Content-Type", "application/x-www-form-urlencoded");// httppost.setheader("Content-Length", ); HOW TO GET CONTENT LENGTH ?// Execute http Post RequesthttpResponse response = httpclIEnt.execute(httppost);
谢谢你的帮助.
解决方法:
也许这可能有助于解决您的问题:
httppost.setheader("Content-Length", String.valueOf(strEntity.getContentLength()));
总结 以上是内存溢出为你收集整理的android-HttpPost setEntity:如何知道内容长度?全部内容,希望文章能够帮你解决android-HttpPost setEntity:如何知道内容长度?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)