问题描述
这是来自 POP3 RFC.
This is from the POP3 RFC.
对某些命令的响应是多行的.在这些情况下,在发送第一行后,在下面清楚地指出响应和 CRLF,发送任何附加行,每行终止通过 CRLF 对.当响应的所有行都已发送后,发送最后一行,由终止八位字节(十进制代码046, ".") 和一个 CRLF 对.如果多行响应中的任何一行以终止八位字节开始,该行是字节填充"的将终止八位字节放在响应的那一行之前.因此,多行响应以五个八位字节结束CRLF.CRLF".在检查多行响应时,客户端检查查看该行是否以终止八位字节开始.如果是,如果除了 CRLF 之外的八位字节跟随,该行的第一个八位字节(终止八位字节)被剥离.如果是这样,如果 CRLF 立即跟在终止符之后,然后是来自 POP 的响应服务器结束,不考虑包含.CRLF"的行多行响应的一部分."
好吧,我对此有疑问,例如 gmail 有时会发送终止八位字节,然后在 NEXT LINE 中发送 CRLF 对.例如:
Well, i have problem with this, for example gmail sometimes sends the termination octet and then in the NEXT LINE sends the CRLF pair. For example:
"+OK blah blah\r\n"
"blah blah.\r\n"
"\r\n"
这种情况非常罕见,但有时会发生,因此显然我无法在这种情况下确定消息的结尾,因为我期待包含 '.\r\n' 的行.说真的,Gmail 是违反 POP3 协议还是我做错了什么?另外我还有第二个问题,英语不是我的第一语言,所以我无法完全理解:
That's very rare, but it happens sometimes, so obviously i'm unable to determine the end of the message in such case, because i'm expecting a line that consists of '.\r\n'. Seriously, is Gmail violating the POP3 protocol or i'm doing something wrong? Also i have a second question, english is not my first language so i cannot understand that completely:
如果多行响应的任何一行以终止八位字节开始,则该行通过将终止八位字节预置到响应的那一行而被字节填充".因此,多行响应以五个八位字节CRLF.CRLF"结束."
究竟何时使用 CRLF.CRLF?有人可以给我一个简单的例子吗?rfc 表示当响应的任何行以终止八位字节开始时使用.但我没有看到任何以 '.' 开头的行在以 CRLF.CRLF 终止的消息中.我查了一下.也许我不明白什么,这就是为什么我要问.
When exactly CRLF.CRLF is used? Can someone gives me a simple example? The rfc says that is used when any line of the response begins with the termination octet. But i don't see any lines that starts with '.' in the messages that are terminated with CRLF.CRLF. I checked that. Maybe i don't understand something, that's why i'm asking.
推荐答案
如果您发布用于读取套接字的代码,将会非常有帮助.但我会尝试用这个例子来回答你问题的第二部分:
It would help very much if you posted the code you are using to read the socket. But I will attempt to answer the second part of your question with this example:
如果响应是:
hello world\r\n
we are doing fine\r\n
.500 is same as one-half\r\n
this is the last line\r\n
服务器必须将其发送为:
the server must send it as:
hello world\r\n
we are doing fine\r\n
..500 is same as one-half\r\n
this is the last line\r\n
.\r\n
所以你可以看到它字节填充"了一个额外的."因此可以将.500"作为响应的一部分加以区分.最后五个八位字节也是 '\r\n.\r\n'.
So you can see where it 'byte stuffed' an extra '.' so the '.500' can be distinguished as part of the response. Also the final five octets are '\r\n.\r\n'.
这篇关于关于 POP3 消息终止八位字节的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!