HTTP content-type
一、简介
Content-Type(内容类型),一般是指网页中存在的Content-Type,用于定义网络文件的类型和网页的编码,决定浏览器将以什么形式、什么编码读取这个文件。简单说,Content-Type告诉客户端实际返回的内容的内容类型。
语法格式如下:
Content-Type:text/html; charset=utf-8
Content-Type:multipart/form-data; boundary=something
二、常见的媒体格式类型如下:
- text/html: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 : 需要在表单中进行文件上传时,就需要使用该格式
三、application/x-www-form-urlencoded 和multipart/form-data的区别
- 两者都是用于提交表单;
- application/x-www-form-urlencoded
GET方式,会将表单中的数据(键值对)经过urlencode编码后追加到url中。
POST方式,会将表单中的数据经过urlencode编码后放在request body 中。
application/x-www-form-urlencoded:该编码方式,会将数据中的非西欧字符转化为十六进制数字的形式。utf8字符集中,每个汉字占3个字节,每个汉字会转化成3个十六进制的数 %XX%XX%XX 的形式。经常处理的下载文件名中文乱码很多时候也是使用这种方式,对于IE,谷歌等浏览器(火狐浏览器有些差异)用到的就是编码方式。
- multipart/form-data
当需要在表单内上传文件时(二进制流数据)时,就需要使用multipart/form-data 编码方式
multipart,顾名思义 多部分。使用该编码方式会将表单进行分割成每个控件(以----boundary为分隔符,将分割控件数据分隔开,在最后以—boundary—结尾)。每个部分必须加上Content-Disposition(form-data) ,对于上传文件还会设置Content-Type。对于上传的不同类型的文件,会自动识别文件类型。对于无法识别的类型设置为application/octet-stream。
参考:
- https://www.runoob.com/http/http-content-type.html
- https://blog.csdn.net/yamadeee/article/details/84250297
HTTP content-type相关推荐
- restTemplate http请求报错:no suitable HttpMessageConverter found for response type and content type
报错信息: org.springframework.web.client.UnknownContentTypeException: Could not extract response: no sui ...
- Posted content type isn't multipart/form-data
版权声明:欢迎转载,请注明沉默王二原创. https://blog.csdn.net/qing_gee/article/details/48712507 在有文件上传的表单提交过程中,搞不好就会报Po ...
- Maven报错解决:Element 'dependency' cannot have character [children], because the type's content type is
在用maven的时候遇到报错: Element 'dependency' cannot have character [children], because the type's content ty ...
- 用VS向SharePoint中部署添加List 并指定应用的Content Type
在SharePoint Project中添加相应的Item,完全用界面的形式向EricSunArticlesList中添加好对应的Column,之后用Feature将List添加到SharePoint ...
- Spring Boot——[Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]解决方案
问题描述 2020-02-13 19:32:04.322 WARN 109508 --- [p-nio-80-exec-4] .m.m.a.ExceptionHandlerExceptionResol ...
- : Content type 'text/plain;charset=UTF-8' not supported
: Content type 'text/plain;charset=UTF-8' not supported
- eclipse 设置 content type 编码格式
前言 Eclipse Version: 2019-12 (4.14.0) 操作 打开Preferences.菜单路径为:Window–> Preferences 在搜索框中输入:content ...
- sendData to ABAP backend via multiple form content type
Created by Jerry Wang, last modified on Aug 20, 2014 使用multipart/form-data的content type通过Javascript向 ...
- 阿里云存储OSS中设置上传文件content type
阿里云存储OSS中设置上传文件ContentType 如果你使用浏览器上传文件,则浏览器会自动在header中设置正确地content type,然后对文件的访问会得到正确地回应. 如果采用编程的方式 ...
- Sharepoint学习笔记—Site Definition系列-- 2、创建Content Type
Sharepoint本身就是一个丰富的大容器,里面存储的所有信息我们可以称其为"内容(Content)",为了便于管理这些Conent,按照人类的正常逻辑就必然想到的是对此进行&q ...
最新文章
- 图像拼接--Parallax-tolerant Image Stitching
- matlab中句点,matlab入门学习(一)
- LeetCode Algorithm 414. 第三大的数
- Angular应用里具有back功能的按钮实现
- [19/03/16-星期六] 常用类_Date时间类DateFormat类
- 【Cocos得知】技术要点通常的积累
- Android自定义view之measure、layout、draw三大流程
- Android 自定义UI-垂直方向的SeekBar
- C语言程序设计(第2版)课后答案
- linux i3 桌面,Linux 桌面平铺管理器 - i3wm
- Windows系统内置测试工具(winsat)
- 基于Scrapy框架对二手车数据进行挖掘
- C#——窗体程序,模拟高温高压锅炉降压处理
- 正确去掉Win7快捷方式小箭头
- mongodb 启动报错 ERROR: child process failed, exited with error number 1
- CleanMyMac2023Mac下载排行最好的清理工具
- 评四女作家的×龙戏凤 (原版)
- FFmpeg入门详解之117:视频监控的架构和流程
- 什么是命名数据网络NDN?
- 9、MyBatis的动态SQL