标签云

微信群

扫码加入我们

WeChat QR Code


Complete list of MIME types

2018年10月22日57分17秒

Can I send file together Json text?

2018年10月22日57分17秒

does it really matter what mime type it has? it's text that gets parsed into an object. wouldn't it be more natural to pass it as text/plain if you want it to be openable in browser without force download, and application/octet-stream if you want it to be automatically downloaded(useful if you're generating it on a webpage intended to be saved locally). Is there really that many people that will need to know the mime type so the downloader can view it with a special json viewer? What am I missing that warrants it a special mime type?

2018年10月22日57分17秒

Using "text/plain" is a bad practice in general. There are, for instance, attacks in the web platform that would allow cross-origin data theft if you fail to send an appropriate MIME type value.

2018年10月22日57分17秒

Internet Explorer sometimes has issues with application/json - blog is offline

2018年10月22日57分17秒

A lot of stuff got put into the text/* section in the early days that would probably be put into the application/* section these days.

2018年10月22日57分17秒

And that's a big mistake imho. JSON is text. Can be read/written by any text editor. That is valuable to know, but cannot be derived from application/json. I think it would have been great to have everything that can be opened with a text editor under text, specific XML doctypes under text/xml/xhtml etc... It would really have helped in organizing.

2018年10月22日57分17秒

I can open a .jpg in my text editor.

2018年10月22日57分17秒

Rohmer - You "can" open anything in a text editor, but a binary format like JPEG or a Windows .exe or a .zip will contain non-printable characters which can actually break many text editors or cause undesired behavior. Try running cat file.jpg for example. Whereas any xml or json file is 100% printable. So I think Stijn de Witt's point is a valid one, despite the fact that yes, it's too late to change now.

2018年10月22日57分17秒

XP84 You can open any binary with a text editor in HEX form. And all the different characters (the 16 of them) are 100% printable. So, by that logic... are all binaries text? Json is not text. Json is (warning: informal loose definition ahead) a text representation of an object (or array of objects)

1970年01月01日00分04秒

JSONP is not really JSON though, it's a technique for passing a JavaScript object literal

2018年10月22日57分17秒

server response must go as text/html. This is true for the ExtJS variant as well.

2018年10月22日57分17秒

How does this have less votes than the above answer, it's more complete and contains definitions..

2018年10月22日57分17秒

DanielWaters The definition of JSON is wrong. It does not need to be dynamically generated or respect query parameters. You can serve a static JSON file. Also, the most upvoted answer has a link to the RFC.

2018年10月22日57分17秒

Also JSONP can be json data assigned to a var.

2018年10月22日57分17秒

usually a reload is enough (faster than restart). Also, note that you can now do "sudo service apache2 reload".

2018年10月22日57分17秒

Ubuntu 12.04 has this by default

2018年10月22日57分17秒

jQuery seems to work with at least 'application/json' and 'text/plain'... I haven't tried all the others though.

2018年10月22日57分17秒

jQuery is capable of working with content-Type: text/plain, content-Type: application/json, content-Type: application/json; charset=UTF-8, contentType: "application/x-www-form-urlencoded; charset=UTF-8"

2018年10月22日57分17秒

"So I personally recommending to use application/x-javascript" is where this answer becomes misleading. GoDaddy does allow compression of application/json, I leverage it on my shared hosting and I wouldn't suggest using a different content type to enable compression anyway, it's simply wrong. It can be done, but it will still be wrong. Using different content types for browser support is one thing, using different content types for server-side compression is another.

2018年10月22日57分17秒

Tools that don't adhere to standards should be avoided whenever possible; use application/json per spec.

2018年10月22日57分17秒

one.beat.consumer while that is true, it's not specific to ExtJs per se. It's a browser limitation (or rather, perhaps, a "security measure").

2018年10月22日57分17秒

Surely it would be better to use text/plain so it doesn't apply any HTML semantics to non-HTML content? Or don't browsers let you extract a frame's content if it's got no DOM?

2018年10月22日57分17秒

To add further confusion: I'm just debugging a similar case on Samsung Galaxy Beam (Android 2.3) with default browser, and the iframe seems to fire load event for application/javascript, application/x-javascript, text/javascript, text/plain, but NOT firing it for application/json nor text/html. As of today, Android <=2.3 is About 50% of the Android market share.

2018年10月22日57分17秒

When did text/javascript become obsolete? I'm still filling up HTML documents with <script type="text/javascript" ... tags.

2018年10月22日57分17秒

It makes no difference for browsers, really. It's just obsolete for RFC standards: rfc-editor.org/rfc/rfc4329.txt

2018年10月22日57分17秒

Oli you can safely drop type="text/javascript" and just do <script>...</script> at least according to HTML5.

2018年10月22日57分17秒

Example of such a situation?

2018年10月22日57分17秒

That's Java EE too :: javax.ws.rs.core.MediaType

2018年10月22日57分17秒

The first part of your answer is wrong. "application/jsonp" is not a valid MIME type. The response body of a JSONP is just JavaScript, so one of the MIME-types for JavaScript has to be used.

2018年10月22日57分17秒

application/vnd.api+json seems to be specifically for apis using json:api, a very narrow specification with its own expectations and format, I don't understand it to be for any API that returns json. Please correct me if I'm wrong

2018年10月22日57分17秒

Hilikus: You are certainly right. I'll fix the answer to reflect this.

2018年10月22日57分17秒