- 在请求头中,Content-Type 定义了请求体的数据类型。
- 在 post 请求中,我们可以通过设置 Content-Type 来指定 post 的参数格式。
- 在响应头中,Content-Type 定义了响应体的数据类型。
默认值
- 对于请求头中的 Content-Type,默认值为 application/x-www-form-urlencoded,即普通表单提交。
- 对于响应头中的 Content-Type,默认值为 text/html,即返回的数据类型为HTML格式。
常见值
请求
- application/json(JSON 数据格式)
- application/x-www-form-urlencoded(表单默认的提交数据格式)
- multipart/form-data(一般用于文件上传)。
响应
- text/html(HTML格式),text/plain(纯文本格式),text/xml(XML格式),image/gif(gif图片格式),image/jpeg(jpg图片格式),image/png(png图片格式)。