本文介绍了如何防止用户代理为无法识别的 MIME 类型显示下载窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您将 Content-Disposition 标头设置为 attachment,这会导致用户代理始终显示该文件的下载窗口.我想这样做与此相反:强制用户代理始终直接显示响应.在这种特殊情况下,我有一个发送 JSON 的 API.我想将它作为 application/json 作为 由规范,但由于用户代理通常无法识别 mime 类型,因此它们会提供一个下载窗口.这使得调试成为一项真正的痛苦,所以如果可以的话,我想解决这个问题.建议?

If you set the Content-Disposition header to attachment, this causes user-agents to always present a download window for that file. I would like to do this opposite of this: force user-agents to always display the response directly. In this particular case, I have an API that's sending JSON. I'd like to serve it as application/json as indicated by the specification, but since user-agents typically don't recognize the mime type, they present a download window. This makes debugging a real pain in the neck, so I'd like to work around this if I can. Suggestions?

推荐答案

我用来在浏览器中调试 JSON 的另一种方法是 JSONView 插件 for Firefox.

Another method I've used to debug JSON in the browser is the JSONView plugin for Firefox.

这篇关于如何防止用户代理为无法识别的 MIME 类型显示下载窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 02:52
查看更多