伪/冒号标题字段的用途 [英] Purpose of Pseudo/Colon Header Fields

查看:128
本文介绍了伪/冒号标题字段的用途的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,我正在寻找关于伪/冒号标题字段目的的一些信息,即我想知道为什么我们有第二种类型的标题字段......

As the title suggests, I'm looking for some information on the purpose of pseudo/colon header fields, i.e. I want to know why we have a second type of header field...

另外 - 我知道在http2中使用伪/冒号头字段代替消息和状态行(^^^我不知道的原因^^^);但是在http1中使用伪/冒号头字段来传递不同的信息(来自状态和请求)?

Also - I know pseudo/colon header fields are used in http2 in place of the message and status lines (^^^the reason for which I don't know^^^); but are pseudo/colon header fields used in http1 to relay different information (from status and request)?

推荐答案

目的伪标题字段用于统一请求/响应信息在SPDY中以及稍后在HTTP / 2中携带的方式(基于SPDY)。

The purpose of the pseudo header fields was to unify the way the request/response information was carried in SPDY and later in HTTP/2 (which is based on SPDY).

当SPDY被设计时(还有HTTP / 2)需要传输以不同方式格式化的请求或响应信息。

When SPDY was designed (but also HTTP/2) there was a need to transport request or response information that is formatted in different ways.

HTTP标头是(键,值)对,这很容易。

The HTTP headers are (key, value) pairs, that's easy.

但是,有HTTP方法的概念。这恰好是请求行的第一个标记,所以它不是一个元组;它的键由其位置(第一个标记)定义,其值是请求行中构成第一个标记的实际字符。

However, there is the concept of the HTTP method. That happens to be the first token of a request line, so it's not a tuple; its key is defined by its position (the first token) and its value is the actual characters present on the request line that form the first token.

与请求相同target和HTTP版本:它们是请求行的第二个和第三个标记。

Same goes with the request target, and HTTP version: they are the second and the third token of the request line.

从概念上讲,HTTP请求可以用这种方式用对来表示,示例:

So conceptually, a HTTP request can be represented with pairs in this way, for example:

(method, GET)  
(target, /)  
(version, HTTP/1.1)  
(Connection, close)  
(Accept, *)  

但是, method,target和version不能用作普通的HTTP标头,因为它们从未被HTTP规范保留为标准HTTP标头名称,人们可以将它们用作自定义HTTP标头名称(想象一下REST)使用版本标题的API。

However, "method", "target" and "version" could not be used as plain HTTP headers, because they were never reserved as standard HTTP header names by the HTTP specification, and people could have used them as custom HTTP header names (imagine a REST API using the "version" header).

HTTP / 2需要一种以同类方式携带这些对的方式,因为它会简化(很多) )协议。

HTTP/2 needed a way to carry those pairs in a homogeneous way, as pairs, because that would have simplified (a lot) the protocol.

因此,为请求和响应行所携带的额外信息引入了特殊名称。这些额外的信息在HTTP / 1.1中是位置的,但在HTTP / 2中是一个正常的对,使HTTP / 2在这方面更加同质:它只是携带对。
这么多,携带请求和响应信息的HTTP / 2帧是相同的,它只是被称为 HEADERS

Hence, the introduction of special names for the extra information carried by the request and response lines. That extra information is positional in HTTP/1.1, but a normal pair in HTTP/2, making HTTP/2 more homogeneous in this respect: it just carries pairs. So much so, that the HTTP/2 frame that carries request and response information is the same and it's just called HEADERS.

伪标题名称选择以冒号开头,因为这将是标题名称的非法字符HTTP / 1.1。
HTTP / 1.1不使用伪标题名称。

The pseudo header names where chosen to begin with a colon because that would be an illegal character for a header name in HTTP/1.1. HTTP/1.1 does not use pseudo header names.

这篇关于伪/冒号标题字段的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆