服务器端请求的含义
Meaning of Server-Side Request
我想知道是否有人可以向我解释服务器端请求的含义。这可能只是我不太明白的术语。对我来说,这听起来像是从服务器到客户端的请求,但我不认为是这样。
这是关于 PHP PSR7 的。我想弄清楚为什么它同时具有 RequestInterface
和 ServerRequestInterface
。我无法在任何地方对它进行任何改进,我也看不出为什么这两者不只是合并到一个界面中。
不能给出比以下更好的答案:
RequestInterface provides the general representation of an HTTP
request message. However, server-side requests need additional
treatment, due to the nature of the server-side environment.
Server-side processing needs to take into account Common Gateway
Interface (CGI), and, more specifically, PHP's abstraction and
extension of CGI via its Server APIs (SAPI). PHP has provided
simplification around input marshaling via superglobals such as:
..
ServerRequestInterface extends RequestInterface to provide an
abstraction around these various superglobals. This practice helps
reduce coupling to the superglobals by consumers, and encourages and
promotes the ability to test request consumers.
我同意 "server-side requests" 的意思不清楚。众所周知,HTTP 请求由客户端(浏览器、机器人、REST API 用户等)发送,毕竟由服务器接收。但是,"server" 这个词在不同的上下文中可能指代不同的事物。
HTTP 请求由 HTTP 服务器(例如 Apache、Nginx 和 Microsoft IIS)接收。服务器提供 Server Application Programming Interface (SAPI),它特别允许对 Web 服务器解析的信息进行后处理。
PHP 引擎 (Zend) 通过其 SAPI (Server API) 模块与不同的环境交互。该模块由多个子模块组成:CLI(命令行接口)、CGI(通用网关接口)、Apache、FPM(FastCGI 进程管理器)等。每个人对 PHP 超全局变量 (example) 的内容都有自己的想法。
原始 HTTP 请求由 Web 服务器解析。 PHP通过SAPI向Web服务器请求解析后的数据进行进一步处理,然后以superglobals的形式传递给我们,特别是。
因此,RequestInterface
表示第一个简单的 HTTP 请求,它没有将其 headers 或部分消息 body 分类为official documentation:
中间接提及的 cookie、上传数据、GET- 或 POST-variables 等
The RequestInterface
and ResponseInterface
have essentially 1:1 correlations with the request and response messages described in RFC 7230. They provide interfaces for implementing value objects that correspond to the specific HTTP message types they model.
它只是为常见的请求参数提供接口,例如URI、方案、查询和端口。
和ServerRequestInterface
表示HTTP消息(请求)的简单表示的解析版本。它介绍了对消息的逻辑分类部分的访问,生成的部分 server-side:上传的文件、cookie、服务器参数等。
我建议将 RequestInterface
视为来自客户端的 HTTP 请求。并且 ServerRequestInterface
作为 已经不完全是 客户端的 请求 =),即服务器修改的原始请求版本 (SAPI).
我想知道是否有人可以向我解释服务器端请求的含义。这可能只是我不太明白的术语。对我来说,这听起来像是从服务器到客户端的请求,但我不认为是这样。
这是关于 PHP PSR7 的。我想弄清楚为什么它同时具有 RequestInterface
和 ServerRequestInterface
。我无法在任何地方对它进行任何改进,我也看不出为什么这两者不只是合并到一个界面中。
不能给出比以下更好的答案:
RequestInterface provides the general representation of an HTTP request message. However, server-side requests need additional treatment, due to the nature of the server-side environment. Server-side processing needs to take into account Common Gateway Interface (CGI), and, more specifically, PHP's abstraction and extension of CGI via its Server APIs (SAPI). PHP has provided simplification around input marshaling via superglobals such as:
..
ServerRequestInterface extends RequestInterface to provide an abstraction around these various superglobals. This practice helps reduce coupling to the superglobals by consumers, and encourages and promotes the ability to test request consumers.
我同意 "server-side requests" 的意思不清楚。众所周知,HTTP 请求由客户端(浏览器、机器人、REST API 用户等)发送,毕竟由服务器接收。但是,"server" 这个词在不同的上下文中可能指代不同的事物。
HTTP 请求由 HTTP 服务器(例如 Apache、Nginx 和 Microsoft IIS)接收。服务器提供 Server Application Programming Interface (SAPI),它特别允许对 Web 服务器解析的信息进行后处理。
PHP 引擎 (Zend) 通过其 SAPI (Server API) 模块与不同的环境交互。该模块由多个子模块组成:CLI(命令行接口)、CGI(通用网关接口)、Apache、FPM(FastCGI 进程管理器)等。每个人对 PHP 超全局变量 (example) 的内容都有自己的想法。
原始 HTTP 请求由 Web 服务器解析。 PHP通过SAPI向Web服务器请求解析后的数据进行进一步处理,然后以superglobals的形式传递给我们,特别是。
因此,RequestInterface
表示第一个简单的 HTTP 请求,它没有将其 headers 或部分消息 body 分类为official documentation:
The
RequestInterface
andResponseInterface
have essentially 1:1 correlations with the request and response messages described in RFC 7230. They provide interfaces for implementing value objects that correspond to the specific HTTP message types they model.
它只是为常见的请求参数提供接口,例如URI、方案、查询和端口。
和ServerRequestInterface
表示HTTP消息(请求)的简单表示的解析版本。它介绍了对消息的逻辑分类部分的访问,生成的部分 server-side:上传的文件、cookie、服务器参数等。
我建议将 RequestInterface
视为来自客户端的 HTTP 请求。并且 ServerRequestInterface
作为 已经不完全是 客户端的 请求 =),即服务器修改的原始请求版本 (SAPI).