http post Content-type: application/json; charset=utf-8
2016-03-30 17:40
627 查看
The header just denotes what the content is encoded in. It is not necessarily possible to deduce the type of the content from the content itself, i.e. you can't necessarily just look at the content and know what to do with it. That's what HTTP headers are for, they tell the recipient what kind of content they're (supposedly) dealing with.Content-type: application/json; charset=utf-8designates the content to be in JSON format, encoded in the UTF-8 character encoding. Designating the encoding is somewhat redundant for JSON, since the default (only?) encoding for JSON is UTF-8. So in this case the receiving server apparently is happy knowing that it's dealing with JSON and assumes that the encoding is UTF-8 by default, that's why it works with or without the header. Does this encoding limit the characters that can be in the message body? No. You can send anything you want in the header and the body. But, if the two don't match, you may get wrong results. If you specify in the header that the content is UTF-8 encoded but you're actually sending Latin1 encoded content, the receiver may produce garbage data, trying to interpret Latin1 encoded data as UTF-8. If of course you specify that you're sending Latin1 encoded data and you're actually doing so, then yes, you're limited to the 256 characters you can encode in Latin1. |
Content-type: application/json;
时,默认编码就是utf-8,不需要额外指定
相关文章推荐
- 实现采用客户/服务器通信模式,基于TCP网络通信协议的多客户端简单应用之案例分析
- 网络编程基础(4) : IO多路复用(多线程)
- linux网络配置命令 ifconfig 、route 、ip 、ip route
- linux 网络管理 监测等相关的工具 ping 、traceroute、ss、netstat
- 全栈工程师眼中的HTTP
- org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
- HTTPS学习(一):工作过程
- NOIP2003 神经网络
- NOIP2014 无线网络发射器选址
- 单机25万tcp长连接后,gc cpu前后比对图
- 【暑假】[网络流]网络流知识总结
- Android HTTP实例 使用GET方法和POST方法发送请求
- ios HTTP协议的理解
- HttpClient详细实例,Httoclient调用https实例,避免https SSL认证
- 卷积神经网络
- 网络摘抄
- 解决IIS7虚拟目录出现HTTP 错误 500.19(由于权限不足而无法读取配置文件)的问题
- struts2获得HttpServlet对象的方式
- android加载网络图片时有效避免OOM
- 使用URLConnection与HttpClient进行接口对接