HTTP 请求格式

标签 http http-headers rfc

我从 RFC2616 第 14.23 节读到:

 Host = "Host" ":" host [ ":" port ] ; Section 3.2.2

但是例子是:

   GET /pub/WWW/ HTTP/1.1
   Host: www.w3.org

为什么“:”和url之间有一个空格,我用firebug和chrome inspect element 发现所有请求都在http header中,key和value之间有一个空格。根据 RFC,没有。这怎么解释?空间是必要的吗?

最佳答案

根据 HTTP/1.1 RFC,冒号和字段值之间的空格不是必需的,但最好使用单个空格。冒号和第一个非空白字符之间的任何空白不包含在字段值中。在此处阅读第 4.2 节:http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html

关于HTTP 请求格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10593573/

相关文章:

node.js - NGINX 未正确设置 X-Forwarded-For

javascript - 有什么方法可以在 'simulate' 上右键另存为命令或使用 JavaScript 在浏览器中强制下载文件?

python发送http响应

spring - Grails 文件下载

python - 为什么我不能只添加 Content-Type :text/html to a text file when Python can?

definition - MPEG-4 (RTP) 中的 'VOP' 是什么?

c - 使用 C 语言制作具有 native 脚本支持的 Web 服务器

Android DownloadManager 中止下载请求 123 : http error 206

c# - System.Net.MailMessage 允许一些无效的电子邮件地址格式

DHCP 选项字段填充