【问题标题】:Manually separating protocol header from body手动将协议头与正文分开
【发布时间】:2015-05-10 14:28:39
【问题描述】:

我正在尝试手工制作一个 HTTP 请求。我的问题是,协议头应该如何与正文分开?是否使用了特殊字节或\r\n 是否足够?

谢谢

【问题讨论】:

标签: c http http-headers


【解决方案1】:

你用双 crlf 将标题与正文分开。

来自维基百科的示例:

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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    • 2015-07-06
    • 2017-09-04
    • 2012-05-10
    相关资源
    最近更新 更多