PHP で HTTP/2 の HPACK を最小実装。目的は HTTP/2 ヘッダーブロックの decode/encode を最小限に扱えるようにすることです。
HPACK の静的テーブル(Static Table)だけを扱うこと
Dynamic Table は実装しない
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <netdb.h> | |
| #include <sys/socket.h> | |
| #include <openssl/ssl.h> | |
| #include <openssl/err.h> | |
| #include <openssl/x509_vfy.h> |
| /* | |
| Minimal TLS Client in C (Architecture Exercise for QUIC Preparation) | |
| This program implements a small TLS + TCP client using OpenSSL. | |
| The goal of this code is not merely to demonstrate how to perform | |
| a TLS request, but to illustrate a connection-oriented design that | |
| resembles modern network protocol libraries. | |
| Instead of writing everything inside main(), the implementation | |
| intentionally separates responsibilities into multiple functions: |
| <?php | |
| /* | |
| Minimal ReactPHP example for querying HTTPS DNS Resource Records (type 65). | |
| This script demonstrates how to: | |
| 1. Query HTTPS DNS records using ReactPHP DNS | |
| 2. Retrieve raw RDATA from the DNS response | |
| 3. Parse SVCB/HTTPS wire format | |
| 4. Extract ALPN values such as "h2" and "h3" |
| <?php | |
| /* | |
| Minimal HTTPS RR (DNS type 65) parser for PHP. | |
| Demonstrates how to parse HTTPS/SVCB records returned by: | |
| dns_get_record($host, 65, ..., true) | |
| Extracts ALPN values such as "h2" and "h3". |
| <?php | |
| /** | |
| * Minimal HTTP/2 Server with ReactPHP Socket (educational demo) | |
| * | |
| * This example demonstrates a minimal HTTP/2 server implemented directly | |
| * on top of ReactPHP's Socket component. It shows how HTTP/2 can be used | |
| * at the frame level without relying on external HTTP/2 libraries. | |
| * | |
| * The implementation is intentionally incomplete and simplified for |
| <?php | |
| /** | |
| * Minimal HTTP/2 Client with ReactPHP Socket (educational demo) | |
| * | |
| * This example demonstrates a minimal HTTP/2 client implemented directly | |
| * on top of ReactPHP's Socket component. It shows how HTTP/2 can be used | |
| * at the frame level without relying on external HTTP/2 libraries. | |
| * | |
| * The implementation is intentionally incomplete and simplified for |
| <?php | |
| declare(strict_types=1); | |
| final class QuicInitialPacketParser | |
| { | |
| private string $buffer = ''; | |
| private int $offset = 0; | |
| public function parse(string $packet): array |