什么规则适用于MIME边界? [英] What rules apply to MIME boundary?
问题描述
当您编写MIME时,您将消息的不同块与特定边界分开。我出于某种原因找不到任何解释这个边界的文档,但是这是我从示例中收集的内容:
-
边界可以是任何一串字母和数字,我即d29a0c638b540b23e9a29a3a9aebc900aeeb6a82。
-
没有生成边界的规则,你可以md5sum你心爱的名字,你走了,你有您的边界。
-
如果您要通过HTTP发送MIME,则必须添加标题Content-Type,指明您执行的操作,以及您的边界内容标题可能如下所示:
multipart / form-data; boundary = d29a0c638b540b23e9a29a3a9aebc900aeeb6a82
-
在邮件正文中,边界应以 - 开头,如:
- d29a0c638b540b23e9a29a3a9aebc900aeeb6a82
但是遵循这些规则(以及这个有用的答案)我无法生成服务器可以接受的POST查询。我错过了什么吗?我搞错了吗?
边界的语法是:
boundary:= 0 * 69< bchars> bcharsnospace
bchars:= bcharsnospace /
bcharsnospace:= DIGIT / ALPHA /'/(/)/
+/_/, / - /。 /
//:/=/?
以及多部分实体的主体具有语法(仅限重要部分):
multipart-body:= [preamble CRLF]
dash-boundary transport-padding CRLF
body-part * encapsulation
close-delimiter transport-padding
[CRLF结语]
dash-boundary:= - boundary
encapsulation:= delimiter transport-padding
CRLF body-part
分隔符:= CRLF破折号边界
close-delimiter:=分隔符 -
前面的 -
对于邮件中使用的每个边界和尾随的 - <是必需的/ code>对于结束边界( close-delimiter )是必需的。因此,具有
边界
作为边界的三个正文部分的多部分主体可以如下所示:
- 边界
1.正文部分
- 边界
2.正文部分
- 边界
3.正文部分
- 边界 -
When you are writing MIME, you separate different chunks of your message with a certain boundary. I failed for some reason to find any documentation explaining this boundary, but here's what I gathered from examples:
Boundary can be any string of letters and numbers, i. e. "d29a0c638b540b23e9a29a3a9aebc900aeeb6a82".
There are no rules for generating the boundary, you can just md5sum the name of your beloved, and here you go, you've got your boundary.
If you are sending MIME over HTTP, you must add a header "Content-Type" specifying that you do, and your boundary, contents of a header may look like this:
multipart/form-data; boundary=d29a0c638b540b23e9a29a3a9aebc900aeeb6a82
In the body of your message, the boundary should be preceded with "--", like:
--d29a0c638b540b23e9a29a3a9aebc900aeeb6a82
But following these rules (and this helpful answer) I failed to generate POST query that server would accept. Am I missing something? Did I get something wrong?
The syntax of a boundary is:
boundary := 0*69<bchars> bcharsnospace bchars := bcharsnospace / " " bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / "_" / "," / "-" / "." / "/" / ":" / "=" / "?"
And the body of a multipart entity has the syntax (only the important parts):
multipart-body := [preamble CRLF] dash-boundary transport-padding CRLF body-part *encapsulation close-delimiter transport-padding [CRLF epilogue] dash-boundary := "--" boundary encapsulation := delimiter transport-padding CRLF body-part delimiter := CRLF dash-boundary close-delimiter := delimiter "--"
The preceeding --
is mandatory for every boundary used in the message and the trailing --
is mandatory for the closing boundary (close-delimiter). So a multipart body with three body-parts with boundary
as boundary can look like this:
--boundary
1. body-part
--boundary
2. body-part
--boundary
3. body-part
--boundary--
这篇关于什么规则适用于MIME边界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!