我想使用内容类型Multipart呈现网页,但我的嗅探器日志始终显示网页上图像的多个GET请求。
这是我的测试代码:
<!DOCTYPE html>
<html>
<head>
<title>multipart/form-data</title>
<header><h2>Testing multipart/form-data</h2></header>
<META HTTP-EQUIV="Content-Type" CONTENT="multipart/related; charset=ISO-8859-1"/>
</head>
<body>
Text outside the <form> tag.
<form
enctype="multipart/form-data"
method="POST"
action="/php/showPostGet.php" > <!-- The enctype attribute can only be used if method="post". -->
Text inside the <form> tag.<br />
<input type="submit" value='TEST'/><br>
<form enctype="multipart/text/plain">
Name1: <input type="text" name="fname" value="ABC"><br>
Name2: <input type="text" name="lname" value="123"><br>
</form>
<br />
<img src="/images/arrow_left.jpg" alt="left">
<img src="/images/arrow_right.jpg" alt="right">
<img src="/images/arrow_up.jpg" alt="up">
<img src="/images/arrow_down.jpg" alt="down">
<br/>
</form>
</body>
<br/>
</html>
当我在这个网页上刷新时,我希望看到一个GET请求,但我看到多个GET请求(一个用于主页面,一个用于ea图像文件)。 像这样:
7 10.738337 163.64.287.173 10.235.5.146 HTTP GET /mdg/HTML/FileUpload/Andy/multipart-form-data.html HTTP/1.1
9 10.739553 10.235.5.146 163.64.287.173 HTTP HTTP/1.1 200 OK (text/html)
Content-Type: text/html; charset=ISO-8859-1\r\n
<META HTTP-EQUIV="Content-Type" CONTENT="multipart/form-data; charset=ISO-8859-1"/>
17 12.945487 163.64.287.173 10.225.57.136 HTTP GET /images/arrow_left.jpg HTTP/1.1
19 12.946704 10.225.57.136 163.64.287.173 HTTP HTTP/1.1 200 OK (JPEG JFIF image)
Content-Type: image/jpeg\r\n
28 14.816313 163.64.287.173 10.225.57.136 HTTP GET /images/arrow_right.jpg HTTP/1.1
30 14.817529 10.225.57.136 163.64.287.173 HTTP HTTP/1.1 200 OK (JPEG JFIF image)
Content-Type: image/jpeg\r\n
41 17.196125 163.64.287.173 10.225.57.136 HTTP GET /images/arrow_up.jpg HTTP/1.1
43 17.197342 10.235.5.146 163.64.287.173 HTTP HTTP/1.1 200 OK (JPEG JFIF image)
Content-Type: image/jpeg\r\n
51 19.060141 163.64.287.173 10.225.57.136 HTTP GET /images/arrow_down.jpg HTTP/1.1
53 19.061358 10.225.57.136 163.64.287.173 HTTP HTTP/1.1 200 OK (JPEG JFIF image)
Content-Type: image/jpeg\r\n
我希望看到1个get请求,然后是几个OK / CONTINUATION消息(带有'boundary ='数据)。 像这样的东西(来自其他网站):
901 15:36:40.100491 10.277.7.10 72.253.197.19 HTTP GET /app/WT/default.aspx?vtbl=1&debugds=320&vzmw3=vzmw3 HTTP/1.1
903 15:36:40.317813 72.253.197.19 10.277.7.10 HTTP HTTP/1.1 200 OK
Content-Type: multipart/mixed; boundary=next.part.8412f441-e4ea-4554-8400-9a003df2f78f\r\n
Content-Type: multipart/mixed; boundary=next.part.8412f441-e4ea-4554-8400-9a003df2f78f\r\n
MIME Multipart Media Encapsulation, Type: multipart/mixed, Boundary: "next.part.8412f441-e4ea-4554-8400-9a003df2f78f"
First boundary: --next.part.8412f441-e4ea-4554-8400-9a003df2f78f\r\n
Content-Type: text/html; charset=utf-8\r\n
905 15:36:40.319315 63.64.187.229 97.253.137.46 HTTP HTTP/1.1 200 OK
Content-Type: multipart/mixed; boundary=next.part.8412f441-e4ea-4554-8400-9a003df2f78f\r\n
Content-Type: multipart/mixed; boundary=next.part.8412f441-e4ea-4554-8400-9a003df2f78f\r\n
906 15:36:40.320116 72.253.197.19 10.247.7.10 HTTP Continuation
答案 0 :(得分:0)
您将无法在HTML中执行此操作。 Content-Type: multipart/...
是HTTP标头,而HTML标记<meta http-equiv="content-type">
支持非常有限的值,如下所示:http://www.w3.org/TR/html-markup/meta.http-equiv.content-type.html#meta.http-equiv.content-type
提供字符编码名称的特殊格式字符串。价值: 以下部分,完全按以下顺序:
- 文字字符串“
text/html;
”。- (可选)一个或多个空格字符。
- 文字字符串“
charset=
”。- 以下之一:
醇>
- 对于HTML语法中的文档:字符编码名称。
- 对于XML语法中的文档:字符串“
UTF-8
”的任何不区分大小写的匹配。
换句话说,由于这是一个HTML文档,唯一允许的内容类型是“text / html”。
您希望在服务器端的HTTP标头中指定“multipart / mixed”(例如,使用PHP标头()或类似标题)。但即便如此,看起来支持它的唯一浏览器是Firefox / Netscape;见How to download multiple files with one HTTP request?