43 lines
1.2 KiB
Markdown
43 lines
1.2 KiB
Markdown
# 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 (for compressed headers)
|
|
* Header parsing (including dictionary)
|
|
* Frame parsing (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.
|
|
|
|
```php
|
|
|
|
// Tradtional request handler
|
|
$http = function (Psr\Http\Message\ServerRequestInterface $request, ?callable $next=null) {
|
|
$promise = new React\Promise\Promise();
|
|
React\Loop\Loop::laterTick(function () use ($request, $promise) {
|
|
// ...
|
|
$promise->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,
|
|
)
|
|
|
|
```
|