HTTP 协议是否支持响应标头中的多种内容类型? [英] Does the HTTP Protocol support multiple content types in response headers?

查看:18
本文介绍了HTTP 协议是否支持响应标头中的多种内容类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否可以返回响应头

I'm wondering if I can return the response header

Content-Type: application/json text/json 

这不合法吗?

HTTP 协议规定 Content-Type 应该是 mediaType 并且 mediaType 定义如下:

The HTTP protocol states that Content-Type should be of mediaType and that mediaType is defined as the following:

   media-type     = type "/" subtype *( ";" parameter )
   type           = token
   subtype        = token

但是我无法解释这意味着什么,有人可以启发我吗?

But I'm having trouble interpreting what this means, can anyone enlighten me?

谢谢!

推荐答案

需要看头域的定义:

http://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.14.17

Content-Type = "Content-Type" ":" 媒体类型

Content-Type = "Content-Type" ":" media-type

所以它采用单一媒体类型,由您上面引用的语法定义.

so it takes a single media-type, which is defined by the grammar you quoted above.

所以答案是:单一类型/子类型,后跟可选参数.

So the answer is: a single type/subtype, followed by optional parameters.

这篇关于HTTP 协议是否支持响应标头中的多种内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆