http - HTTP 标头是用什么语言编写的?
问题描述
以下是 HTTP 标头。这段代码是用什么语言或语法编写的?
HTTP/2.0 200 OK
Content-type: text/html
Set-Cookie: yummy_cookie=choco
Set-Cookie: tasty_cookie=strawberry
它不是 JavaScript 或 PHP。这是取自https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies的另一个示例
GET /sample_page.html HTTP/2.0
Host: www.example.org
Cookie: yummy_cookie=choco; tasty_cookie=strawberry
解决方案
它们是 HTTP 事实标准定义的一部分,被编入所谓的 RFC 或 Request For Comments。RFC 是关于人们所知的 Internet 基础的事实标准的集合。
见https://www.rfc-editor.org/rfc/rfc2616#page-31:
4.2 消息头
HTTP 头字段,包括 general-header(第 4.5 节)、request-header(第 5.3 节)、response-header(第 6.2 节)和 entity-header(第 7.1 节)字段,遵循与第 7.1 节中给出的相同的通用格式RFC 822 [9] 的 3.1。每个标头字段由一个名称后跟一个冒号(“:”)和字段值组成。字段名称不区分大小写。字段值可以在任意数量的 LWS 之前,但最好使用单个 SP。通过在每个额外行之前至少使用一个 SP 或 HT,标题字段可以扩展到多行。在生成 HTTP 结构时,应用程序应该遵循已知或指示的“通用形式”,因为可能存在一些无法接受超出通用形式的任何实现的实现。
message-header = field-name ":" [ field-value ] field-name = token field-value = *( field-content | LWS ) field-content = <the OCTETs making up the field-value and consisting of either *TEXT or combinations of token, separators, and quoted-string>
推荐阅读
- apache-spark - 在 Databricks / Spark 中的 SQL 中为变量分配动态值
- php - 跟踪用户日志的最佳方式?
- php - PHP,SQL根据下拉选择菜单从数据库中填充信息
- python - TensorFlow SavedModel 方法远大于 h5
- azure - 如何配置不在
web.config 的部分? - java - 如何在中缀到后缀之后将整数组合在一起
- python - ZeroDivisionError pandas 仅当索引不是 datetimeindex 时
- azure-web-app-service - AdalServiceException:AADSTS7000215:提供的客户端密码无效
- json - Dart:jsonEncode 是完全可预测的吗?
- python - 如何从所有值为空的数据框中删除行