android-HttpPost setEntity:如何知道内容长度?

android-HttpPost setEntity:如何知道内容长度?,第1张

概述这个问题已经在这里有了答案:            >            Howtosetcontent-lengthinandroid?                                    1个我已经设置了几乎所有数据:Stringcapcha=editText.getText().toString();

这个问题已经在这里有了答案:            >            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&param2=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:如何知道内容长度?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1087413.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存