Native HTTP/2 support for ReactPHP
Go to file
Christopher Vagnetoft d41cfb1be2 Header parsing improvements
* Made headers public readonly in HeadersFrame
* Fetching headers by value implemented
* Initial tests for HeaderBag
2024-07-25 14:41:21 +02:00
src Header parsing improvements 2024-07-25 14:41:21 +02:00
tests Header parsing improvements 2024-07-25 14:41:21 +02:00
.gitignore Initial commit 2024-02-24 20:44:06 +01:00
composer.json Initial commit 2024-02-24 20:44:06 +01:00
phpstan.neon Initial commit 2024-02-24 20:44:06 +01:00
phpunit.xml Initial commit 2024-02-24 20:44:06 +01:00
README.md make frame fromBinary public, improve docs 2024-02-27 00:21:54 +01:00

HTTP/2 Support for ReactPHP

This is a project that is exploring the feasability and practicality of bringing HTTP/2 to ReactPHP while staying true to the ReactPHP philosophy. The main rationale for this is to eventually enable native support for gRPC. Plus it is neat!

Status

Currently implemented:

  • Huffman encoding and decoding (for compressed headers)
  • Header parsing and packing (only static dictionary, no dynamic dictionary)
  • Frame parsing core (not all frame types)

Notes

  • As HTTP/2 is multiplexed, use of promises will be essential for the library as well as any client code. Without promises, all requests will be blocking and synchronous, which isn't necessarily bad but still wasteful.

Mockup

The idea is tho end up with something like this. Expect a lot to change tho.


// Tradtional request handler
$http = function (Psr\Http\Message\ServerRequestInterface $request, ?callable $next=null) {
    $promise = new React\Promise\Promise(function ($resolve) use ($request) {
        // ...
        $resolve($response);
    });
    return $promise;
};

// HTTP/2 request handler
$http2 = new NoccyLabs\React\Http2\Http2Middleware($http);

// React HTTP sever
$server = new React\Http\HttpServer(
    $http2,
    $http,
)