我正在尝试手工制作一个 HTTP 请求。我的问题是,协议(protocol)头应该如何与主体分开?是否使用了特殊字节或者 \r\n
就足够了?
谢谢
最佳答案
通过双 crlf 将 header 与正文分开。
来自维基百科的示例:
HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
ETag: "3f80f-1b6-3e1cb03b"
Content-Type: text/html; charset=UTF-8
Content-Length: 138
Accept-Ranges: bytes
Connection: close
<html>
<head>
<title>An Example Page</title>
</head>
<body>
Hello World, this is a very simple HTML document.
</body>
</html>
关于c - 手动将协议(protocol)头与正文分离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30152557/