我怎样才能prevent从$ P $用户代理psenting为无法识别的MIME类型下载窗口? [英] How can I prevent user-agents from presenting a download window for unrecognized mime types?

查看:102
本文介绍了我怎样才能prevent从$ P $用户代理psenting为无法识别的MIME类型下载窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您设置了内容处置附件,这将导致用户代理总是present该文件的下载窗口。我想这样做相反的是:强制用户代理总是直接显示的响应。在这种特殊情况下,我有一个的发送JSON的API。我想以服务为应用程序/ JSON 按规范表示,但由于用户代理通常不承认MIME类型,它们present一个下载窗口。这使得调试在脖子上一个真正的痛苦,所以我想,如果我可以解决这个问题。建议?

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在浏览器中的另一种方法是的 Firefox的插件JSONView

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

这篇关于我怎样才能prevent从$ P $用户代理psenting为无法识别的MIME类型下载窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆