如何通过 API 发出 HTTP/2 请求
How to make HTTP/2 requests via API
如何使用 PHP 向 API 发出 HTTP/2 请求?
我知道HTTP/2二进制编码request/response和多路复用
更复杂
任何人都可以提供 link 教程或示例如何使用 HTTP/2 处理请求吗?
https://www.reddit.com/r/PHP/comments/301ncp/http2_support_for_curl_merged/
This simply means that you can optionally tell curl_*() to communicate with the remote server via HTTP/2.0. If the remote server doesn't support the protocol the two parties will speak HTTP/1.1 as before. There are two scenarios in PHP userland where you can benefit from the use of HTTP/2.0 in a curl client:
- You're retrieving multiple resources from the same site concurrently over the same connection; you may experience performance improvement by avoiding the "head-of-line" blocking problem because HTTP/2.0 allows the multiplexing of multiple transfers concurrently over the same TCP connection.
- You're connecting via HTTPS (h2). Encrypted h2 sessions are negotiated as part of the TLS handshake via the TLS ALPN extension. This means you can establish the crypto session with fewer TCP roundrips via HTTP/2.0 than you'd be able to do with HTTP/1.1 (a performance benefit).
cURL 基本上会为您处理这些工作。
如何使用 PHP 向 API 发出 HTTP/2 请求?
我知道HTTP/2二进制编码request/response和多路复用
更复杂任何人都可以提供 link 教程或示例如何使用 HTTP/2 处理请求吗?
https://www.reddit.com/r/PHP/comments/301ncp/http2_support_for_curl_merged/
This simply means that you can optionally tell curl_*() to communicate with the remote server via HTTP/2.0. If the remote server doesn't support the protocol the two parties will speak HTTP/1.1 as before. There are two scenarios in PHP userland where you can benefit from the use of HTTP/2.0 in a curl client:
- You're retrieving multiple resources from the same site concurrently over the same connection; you may experience performance improvement by avoiding the "head-of-line" blocking problem because HTTP/2.0 allows the multiplexing of multiple transfers concurrently over the same TCP connection.
- You're connecting via HTTPS (h2). Encrypted h2 sessions are negotiated as part of the TLS handshake via the TLS ALPN extension. This means you can establish the crypto session with fewer TCP roundrips via HTTP/2.0 than you'd be able to do with HTTP/1.1 (a performance benefit).
cURL 基本上会为您处理这些工作。