简体   繁体   中英

Is there a mime-type that is invalid by definition?

I am writing an http middleware using Node.js that responds to requests with a certain content-type set as header. Now I'd like to unit test that the middleware does not respond to requests with the "wrong" content-type.

Of course, I can basically use any content-type for this that is not intended to be supported by my component, but I was wondering whether there is a content-type that is intended to be used in this cases (similar to the domain example.com which is for illustrative purposes only and can be used in documentation.

Is there something such as content/invalid or something like this?

In short: no. You can have a "personal" or "vanity" mime type by prepending with prs. Media Type Specification, Personal/Vanity type ...but there is no mime that is, by definition, invalid. There are obsolete and deleted ones, but they are not by definition invalid.

So you can pretty much do whatever you want, such as content/prs.golo.impossibru or use an oxymoron, like content/swift-government-action - or whatever. It's kind of like how in some languages 'foo' and 'bar' are such common example variable names, where in other languages that just isn't done. In mime types there just appears to be no such convention.

This is at least partially because its almost never the mime type that is invalid, because if an error will occur it's usually that the mime is one thing but the content actually sent does not match it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM