安卓 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 ...
随机推荐
- 一个WEB应用的开发流程
转载:http://www.51testing.com/html/56/n-3721856.html 先说项目开发过程中团队人员的分工协作. 一.人员安排 毕业至今的大部分项目都是独立完成,虽然也有和 ...
- Slitaz 中文定制手册
源: http://www.simplemind.info/technolife/opensource/slitaz-cn.html 有关 Slitaz 的一些网站 slitaz的网站:http:// ...
- Hbase总结(六)hbase37个笔试题
下面试题是摘自互联网的基础上自己加了选项说明解释便于自己以后看时方便节省时间 1. HBase来源于哪篇博文? C A The Google File System B MapReduce C Big ...
- javax.validation.UnexpectedTypeException: No validator could be found for constraint 'org.hibernate.validator.constraints.Length' validating type
使用hibernate validator出现上面的错误, 需要注意: @NotNull 和 @NotEmpty 和@NotBlank 区别 @NotEmpty 用在集合类上面@NotBlank 用 ...
- [Python]将Excel文件中的数据导入MySQL
Github Link 需求 现有2000+文件夹,每个文件夹下有若干excel文件,现在要将这些excel文件中的数据导入mysql. 每个excel文件的第一行是无效数据. 除了excel文件中已 ...
- Lintcode: Add Two Numbers
C++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * List ...
- Cocon90.Db调用方法
Cocon90.DB 使用说明 开源库:https://github.com/Cocon90/Cocon90.Db Sqlite位置:https://www.nuget.org/packages/Co ...
- Go语言中Path包用法
// path package main import ( "fmt" "os" "path" "path/filepath&qu ...
- Go语言中的RPC调用
首先,说一下目录结构: 一.HttpRPC 1.建立服务文件 /*Go RPC的函数只有符合下面的条件才能被远程访问,不然会被忽略,详细的要求如下: 函数必须是导出的(首字母大写) 必须有两个导出类型 ...
- Aerospike系列:3:aerospike特点分析
1. 数据存放 数据可以放内存,也可以放SSD. 数据放内存时速度肯定会很快,但这和memcache一样,相比memcache性能并没有优势 数据放内存时可以进行持久化配置,但文档只有一个地方提了 ...