6

I am using a single JSON response format to cover a number of possible responses.

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.

i.e.

mime-type : video/mp4

Client plays the video

mime-type : text/html

Client launches a browser with the given URL

What I would like to know, is if there is a "standard" mime-type to cover an empty resource.
I know I can use a vendor specific mime-type, and most likely will, but it made me question.

Thanks.

abovethewater
  • 471
  • 4
  • 5
  • 1
    I think the answer is no there isn't as a media type can only be defined if something actually exists. Alternatively I would argue that depending on the system there may be a default for example one system may default to send "text/plain" while a web form may result in "multipart/form-data" by default. I think it really depends on where the data is being sent from and how it is defined when sent. – Daniel Tate Jul 25 '14 at 02:55
  • I've seen `application/x-empty` used in cases where there was no content provided. Perhaps you can use that one? – Jens Feb 13 '16 at 22:28

3 Answers3

3

I agree with DanielTate's comment on the original question: I don't think there is a "null media type" (media type a.k.a. MIME type). I haven't looked through the entire IANA registry, but I very much doubt there's anything there. 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".

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 (i.e., 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"?

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?

Community
  • 1
  • 1
Hawkeye Parker
  • 7,817
  • 7
  • 44
  • 47
  • Maybe there is a better way to do this, but one use case I can see is to send an Accept header in HTTP to specify that you don't expect to get anything back. – Thayne Oct 25 '19 at 20:08
1

The IANA reserves "example" for, well, example purposes. But since "example" shall never be used as a real mime type, example/example could serve as an (internally used) compatible "null" MIME type.

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

example

Note: The 'example' media type is used for examples. Any subtype following the media type syntax may be used in those examples. No subtype can be registered with IANA. For more information see[RFC4735].

Note: The occurrence of an 'example' media type as a media type outside of examples, e.g. 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.

JensG
  • 13,148
  • 4
  • 45
  • 55
0

jus add a comma at the end

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," ) ) {