Android http Request / Response ContentType
来源:互联网 发布:常用的sql语句 编辑:程序博客网 时间:2024/05/16 03:13
客户端在进行http请求服务器的时候,需要告诉服务器请求的类型,服务器在返回给客户端的数据的时候,也需要告诉客户端返回数据的类型。
这个类型就是 ContentType ,不同的ContentType 会影响客户端/服务器所看到的效果。contentType: 告诉服务器,我要发什么类型的数据
1、默认的ContentType为 text/html 也就是网页格式.
- text/plain :纯文本格式
- text/xml : XML格式
- image/gif :gif图片格式
- image/jpeg :jpg图片格式
- image/png:png图片格式
以application开头的媒体格式类型:
- application/xhtml+xml :XHTML格式
- application/xml : XML数据格式
- application/atom+xml :Atom XML聚合格式
- application/json : JSON数据格式
- application/pdf :pdf格式
- application/msword : Word文档格式
- application/octet-stream : 二进制流数据(如常见的文件下载)
- application/x-www-form-urlencoded : <form encType=””>中默认的encType,form表单数据被编码为key/value格式发送到服务器(表单默认的提交数据的格式)
另外一种常见的媒体格式是上传文件之时使用的:
- multipart/form-data : 需要在表单中进行文件上传时,就需要使用该格式
以上就是我们在日常的开发中,经常会用到的若干content-type的内容格式。
比如:
URL realUrl = new URL(url); //打开和URL之间的连接 conn = realUrl.openConnection(); //设置通用的请求属性 conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "application/json");
阅读全文
0 0
- Android http Request / Response ContentType
- JSP request对象、response对象、contentType属性,HTTP状态码
- pageEncoding,contentType,response/request.setCharacterEncoding
- HTTP Request/Response header
- HTTP Request and Response
- HTTP Request 和Response
- Http Request 和 Response
- Response.ContentType
- response.contenttype
- Response.ContentType
- Response.ContentType
- Response.ContentType
- Http Request header/Response header
- Http Request Response Header 说明
- Common HTTP Response Codes & HTTP Request Methods
- Http Request and Http Response in Java
- Advanced Request and Response HTTP Header Viewer
- http协议:request 和 response包组成
- sencha-touch 动态改变某个控件样式
- 海航集团负债率得到海南省省长刘赐贵肯定
- Android 自定义线程池的实战
- Android Studio添加aar
- 异或运算实现两个数的交换
- Android http Request / Response ContentType
- ApiCloud基础
- Android 缓存
- Android github 快速实现多人协作
- Android 一个对sharedpreferences 数据进行加密的开源库
- Android 图片压缩、照片选择、裁剪,上传、一整套图片解决方案
- Android Gson的使用总结
- Android Json处理框架
- SpringMVC @Transactional注解方式事务失效的解决办法