浏览器支持多部分响应 [英] Browser support of multipart responses
问题描述
我想使用multipart / mixed创建HTTP响应,但我不确定哪些浏览器支持它;从客户的角度来看,如果它听起来那么方便。
说实话,我不需要专门的内容类型。我只想在同一个响应中传输多个文件;也许还有更多使用的内容类型。
I would like to create a HTTP response, using multipart/mixed, but I'm not sure which browsers support it; and if it's as convenient as it sounds, from the client's point of view. To be honest, I do not need specifically that content type. I just want to transmit more than one file in the same response; maybe there's another content-type more used.
推荐答案
我已经测试了它,使用自制服务器和简单的响应。不确定响应是否格式正确,因为没有浏览器100%理解它。但结果如下:
I've tested it, with a home-made server and a simple response. Not sure if the response is well-formed because no browser understands it 100% OK. But here are the results:
- Firefox 3.5 :仅渲染最后一部分,其他部分将被忽略。
- IE 8 :将所有内容显示为文本/纯文本,包括边界。
- Chrome 3 :将所有内容保存在一个文件中,不会呈现任何内容。
- Safari 4 :将所有内容保存在一个文件中,没有渲染。
- Opera 10.10 :奇怪的东西。开始将第一部分渲染为纯文本/文本,然后清除所有内容。加载进度条挂起31%。
- Firefox 3.5: Renders only the last part, others are ignored.
- IE 8: Shows all the content as if it were text/plain, including the boundaries.
- Chrome 3: Saves all the content in a single file, nothing is rendered.
- Safari 4: Saves all the content in a single file, nothing is rendered.
- Opera 10.10: Something weird. Starts rendering the first part as plain/text, and then clears everything. The loading progress bar hangs on 31%.
这是完整的回复,如果有人发现任何错误,请告诉我,我会再试一次:
Here's the complete response, if anyone finds any error, please tell me and I'll try again:
HTTP/1.1 200 OK
Date: Tue, 01 Dec 2009 23:27:30 GMT
Vary: Accept-Encoding,User-Agent
Content-Length: 681
Content-Type: Multipart/mixed; boundary="sample_boundary";
Multipart not supported :(
--sample_boundary
Content-Type: text/css; charset=utf-8
Content-Location: http://localhost:2080/file.css
body
{
background-color: yellow;
}
--sample_boundary
Content-Type: application/x-javascript; charset=utf-8
Content-Location: http://localhost:2080/file.js
alert("Hello from a javascript!!!");
--sample_boundary
Content-Type: text/html; charset=utf-8
Content-Base: http://localhost:2080/
<html>
<head>
<link rel="stylesheet" href="http://localhost:2080/file.css">
</head>
<body>
Hello from a html
<script type="text/javascript" src="http://localhost:2080/file.js"></script>
</body>
</html>
--sample_boundary--
这篇关于浏览器支持多部分响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!