0

我想使用内容类型 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 &lt;form&gt; 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 &lt;form&gt; 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 个获取请求,然后是几个 OK/CONTINUATION 消息(带有“边界 =”数据)。像这样的东西(来自另一个网站):

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
4

1 回答 1

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 。内容类型

提供字符编码名称的特殊格式的字符串。值:以下部分,完全按照以下顺序:

  1. 文字字符串“ text/html;”。
  2. 可选地,一个或多个空格字符。
  3. 文字字符串“ charset=”。
  4. 以下之一:
    • 对于 HTML 语法中的文档:字符编码名称。
    • 对于 XML 语法中的文档:字符串“”的任何不区分大小写的匹配UTF-8

换句话说,因为这是一个 HTML 文档,所以唯一允许的内容类型是“text/html”。

您想在服务器端的 HTTP 标头中指定“multipart/mixed”(例如,使用 PHP header() 或类似方法)。但即便如此,看起来唯一支持它的浏览器是/曾经是 Firefox/Netscape;请参阅如何使用一个 HTTP 请求下载多个文件?

于 2013-11-04T22:59:35.813 回答