c - 手动将协议(protocol)头与正文分离

标签 c http http-headers

我正在尝试手工制作一个 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/

相关文章:

我能否在调试时准确控制函数返回的内容(即 rand())?

android - Flutter: InternalLinkedHashMap<String, dynamic >' has no instance method ' cast' with matching arguments

java - 未将 JAX-RS 自定义 header 添加到重定向响应

http - Cache-Control s-maxage header 是否会覆盖浏览器缓存的 Expires header ?

php - YouTube 没有显示为推荐人?

c - GDB 单步执行汇编并显示下一条将要执行的指令。

c - 为什么我们使用两个间接运算符来访问字符串数组

c++ - C++ 中的 Doc 字符串工具

angular2 http post 静默失败

Android:发送 HTTP POST 时出现 UnknownHostException