简体   繁体   English

是否有标准的“空” mime 类型

[英]Is there a standard 'null' mime-type

I am using a single JSON response format to cover a number of possible responses.我使用单一的 JSON 响应格式来涵盖许多可能的响应。

The response contains a field that, optionally, contains a link to an external resource.响应包含一个字段,该字段可选地包含指向外部资源的链接。

The response is valid, regardless of whether this field is populated.无论是否填充此字段,响应都是有效的。

I am using a separate mime-type field to dictate how the client should handle said field.我使用单独的 mime 类型字段来指示客户端应如何处理所述字段。

ie IE

mime-type : video/mp4

Client plays the video客户端播放视频

mime-type : text/html

Client launches a browser with the given URL客户端使用给定的 URL 启动浏览器

What I would like to know, is if there is a "standard" mime-type to cover an empty resource.我想知道的是,是否有一个“标准”的 MIME 类型来覆盖空资源。
I know I can use a vendor specific mime-type, and most likely will, but it made me question.我知道我可以使用供应商特定的 MIME 类型,而且很可能会使用,但这让我产生了疑问。

Thanks.谢谢。

I agree with DanielTate's comment on the original question: I don't think there is a "null media type" (media type aka MIME type).我同意 DanielTate 对原始问题的评论:我认为没有“空媒体类型”(媒体类型又名 MIME 类型)。 I haven't looked through the entire IANA registry , but I very much doubt there's anything there.我还没有浏览过 整个 IANA 注册机构,但我非常怀疑那里是否有任何内容。 The media type RFC doesn't appear to mention anything like this -- I haven't read the whole thing, but did scan the TOC and search around for "null" "empty" "invalid".媒体类型 RFC似乎没有提到这样的事情——我没有读过整篇文章,但确实扫描了 TOC 并搜索了“空”“空”“无效”。

What's clear is: media type is supposed to be metadata about something .明确的是:媒体类型应该是关于某事的元数据。 Given your question, I'm trying to guess why you might be thinking about a null media type (if you added some specific json examples in your question, it might be clearer), but, generally speaking, it just doesn't make much sense: in theory, you shouldn't need to describe nothing (ie, a non-existing resource) with any kind of media type: there's already nothing there, so why describe it further as having a "null media type"?鉴于您的问题,我试图猜测您为什么可能会考虑空媒体类型(如果您在问题中添加了一些特定的 json 示例,它可能会更清楚),但是,一般来说,它并没有太大作用意义:理论上,您不需要用任何类型的媒体类型描述任何内容(即不存在的资源):那里已经没有任何内容,那么为什么还要将其描述为“空媒体类型”呢?

If I understand your situation correctly, when there is no resource, I would just use an empty string.如果我正确理解你的情况,当没有资源时,我只会使用一个空字符串。 Maybe that's the null media type :) But, for some reason, you seem to really want to specify a media type in your response, even when there's no resource (or no link).也许那是空媒体类型 :) 但是,出于某种原因,您似乎真的想在响应中指定媒体类型,即使没有资源(或没有链接)。 Why is that?这是为什么?

The IANA reserves "example" for, well, example purposes. IANA 保留“示例”用于示例目的。 But since "example" shall never be used as a real mime type, example/example could serve as an (internally used) compatible "null" MIME type.但是由于“example”永远不会用作真正的 MIME 类型,因此example/example可以用作(内部使用的)兼容的“null”MIME 类型。

https://www.iana.org/assignments/media-types/media-types.xhtml#examples https://www.iana.org/assignments/media-types/media-types.xhtml#examples

example例子

Note: The 'example' media type is used for examples.注意:'example' 媒体类型用于示例。 Any subtype following the media type syntax may be used in those examples.在这些示例中可以使用遵循媒体类型语法的任何子类型。 No subtype can be registered with IANA.不能向 IANA 注册任何子类型。 For more information see[RFC4735].更多信息参见[RFC4735]。

Note: The occurrence of an 'example' media type as a media type outside of examples, eg in a Content-Type header, is an error and should be reported to the implementor.[RFC2045][RFC2046] specifies that Content Types, Content Subtypes, Character Sets, Access Types, and conversion values for MIME mail will be assigned and listed by the IANA.注意:“示例”媒体类型作为示例之外的媒体类型出现,例如在 Content-Type 标头中,是一个错误,应该报告给实现者。 [RFC2045][RFC2046] 指定内容类型,内容MIME 邮件的子类型、字符集、访问类型和转换值将由 IANA 分配和列出。

只需在最后添加一个逗号

if( checkType( $_FILES["CV"]["type"], "application/pdf,image/jpeg,image/png,video/mp4,audio/mpeg,application/msword,application/excel,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.wordprocessingml.document," ) ) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求具有文本/纯MIME类型的JSONP - Request JSONP with text/plain MIME Type 是否可以更改ajax结果的内容/ MIME类型? - Is it possible to change the content/mime type of ajax results? 检查文件是否存在并返回mime类型 - Check if file exists and return mime type JSONP脚本返回MIME类型错误 - JSONP script returning MIME Type error Codeigniter中ajax上传的奇怪MIME类型 - Weird MIME type on ajax upload in Codeigniter javascript:MIME类型('text / html')无法执行,并且启用了严格的MIME类型检查 - javascript: MIME type ('text/html') is not executable, and strict MIME type checking is enabled 拒绝执行脚本,因为 MIME 类型('text/html')不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script because MIME type ('text/html') is not executable, and strict MIME type checking is enabled 拒绝从'*'执行脚本,因为它的MIME类型('application / json')不可执行,并且严格的MIME类型为che - getting Refused to execute script from '*' because its MIME type ('application/json') is not executable, and strict MIME type che 使用MIME类型application / json的跨源读取阻止(CORB) - Cross-Origin Read Blocking (CORB) with MIME type application/json ajax错误:资源被解释为脚本,但以MIME类型text / json传输: - ajax error: Resource interpreted as Script but transferred with MIME type text/json:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM