安卓 AsyncHttpClient - “Content-Type not allowed!”
使用 http://loopj.com/android-async-http/ 的异步网络请求工具使用BinaryHttpResponseHandler来完成文件下载时总是报错,“org.apache.http.client.HttpResponseException: Content-Type not allowed!”。若缺少某个请求的类型,比如我下载一个jpg文件,只要加上“image/jpg;charset=UTF-8” ,若对于html文件后来加上“text/html;charset=UTF-8” 就解决问题了。完整代码如下:
String[] allowedContentTypes = new String[] { "text/html;charset=UTF-8", "image/jpg;charset=UTF-8"};
String urlStr="your request url";
HttpUtil.get(urlStr, new BinaryHttpResponseHandler(allowedContentTypes) {
public void onSuccess(int i, org.apache.http.Header[] headers, byte[] bytes) {
Log.d("myingwill","ok");
}
public void onFailure(int i, org.apache.http.Header[] headers, byte[] bytes, java.lang.Throwable throwable) {
Log.d("myingwill",throwable.toString());
for (org.apache.http.Header header : headers)
{
Log.i("myingwill", header.getName()+" / "+header.getValue());
}
}
});
安卓 AsyncHttpClient - “Content-Type not allowed!”的更多相关文章
- Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...
- DOM解析XML报错:Content is not allowed in prolog
报错内容为: Content is not allowed in prolog. Nested exception: Content is not allowed in prolog. 网上所述总结来 ...
- Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...
- SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...
- SharePoint自动化系列——Content Type相关timer jobs一键执行
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...
- 转载 SharePoint【Site Definition 系列】– 创建Content Type
转载原地址: http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...
- the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header
the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header ...
- 转:通过ant来批量执行jmeter脚本,并生成报告(附: 生成报告时报“Content is not allowed in prolog”这个错误的解决方案)
最近在使用jmeter写脚本来进行测试,最终写了很多份脚本,然后,就在想,这么多脚本,我不可能一个一个的手动去点啊,有没有什么办法来批量运行Jmeter脚本呢? 这个时候,自然而然地想到了万能的ant ...
- Springs Element 'beans' cannot have character [children], because the type's content type is element-only
Springs Element 'beans' cannot have character [children], because the type's content type is element ...
- Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in
1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframe ...
随机推荐
- 机器学习之深入理解SVM
在浏览本篇博客之前,最好先查看一下我写的还有一篇文章机器学习之初识SVM(点击可查阅哦).这样能够更好地为了结以下内容做铺垫! 支持向量机学习方法包括构建由简至繁的模型:线性可分支持向量机.线性支持向 ...
- Sublime Text 3 配置 PHPCS 插件
Download php code sniffer addon via Package Control in ST3. Download The php-cs-fixer File From This ...
- HTTP服务原理
第1章 HTTP服务介绍 1.1 简述用户访网站流程 a 进行域名信息的DNS解析 dig +trace 获得www.oldboyedu.com ip地址信息 b 进行与网站服务器建立连接,tcp三次 ...
- oracle 对表赋权限
grant select,insert,delete,update on yizhen123.tpp_t_dz_yinglian to wangyd;
- Office办公 SVG的图片文件如何保存为PNG
用浏览器打开,然后右击图片另存为PNG 再用PS打开可以看到就是没有背景的PNG图片了
- Java多线程-BlockingQueue-ArrayBlockingQueue-LinkedBlockingQueue
前言: BlockingQueue很好的解决了多线程中,如何高效安全“传输”数据的问题.通过这些高效并且线程安全的队列类,为我们快速搭建高质量的多线程程序带来极大的便利.本文详细介绍了Blocking ...
- postman添加cookie
检索cookie: 1.启动拦截器(需安装Postman Interceptor) 2.在测试部分,你可以使用responseCookies对象,他将返回一个cookie对象的数组.使用postman ...
- Tomcat中的session实现
Tomcat中一个会话对应一个session,其实现类是StandardSession,查看源码,可以找到一个attributes成员属性,即存储session的数据结构,为ConcurrentHas ...
- new malloc
https://blog.csdn.net/happyxieqiang/article/details/50775847 0. 属性 new/delete是C++关键字,需要编译器支持.m ...
- 【Linux】常见Linux默认的shell
常见的操作系统下的shell: Linux下默认的shell是Bourne Again shell(bash) Solaris和FreeBSD下默认的是Bourne shell(sh) AIX系统下默 ...