SwooleRequestConverter
Turns a SwooleRequestSnapshot into a PSR-7 request.
Swoole hands over its own request shape rather than CGI-style server params, so this is where the two are reconciled. Three details are easy to get wrong and each breaks something specific:
$request->serverkeys are lowercase (request_method, notREQUEST_METHOD), so everything reading CGI names sees nothing unless they are translated. - Swoole supplies noSCRIPT_NAME.Quiote\Routing\Routingreads it when generating URLs, so omitting it corrupts generated links rather than failing loudly. HenceSwooleConverterOptions::$scriptName. -content-type/content-lengthbecome bareCONTENT_TYPE/CONTENT_LENGTHwithout theHTTP_prefix, matching CGI —Quiote\Request\WebRequestreads$_SERVER['CONTENT_TYPE']directly.
Reverse-proxy correction is deliberately not done here: every runtime funnels through WorkerRequestFactory, which applies it uniformly.
Synopsis
Section titled “Synopsis”final class SwooleRequestConverter
| Source | SwooleRequestConverter.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(SwooleConverterOptions $options = new SwooleConverterOptions(…), Psr17Factory $psr17 = new Psr17Factory(…), ClockInterface $clock = new SystemClock(…)): mixed
| Parameter | Type | Description |
|---|---|---|
$options | SwooleConverterOptions | |
$psr17 | Psr17Factory | |
$clock | ClockInterface |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
toPsr7(SwooleRequestSnapshot $snapshot): ServerRequestInterface | Builds a PSR-7 server request from a Swoole request snapshot. |
toPsr7()
Section titled “toPsr7()”public function toPsr7(SwooleRequestSnapshot $snapshot): ServerRequestInterface
Builds a PSR-7 server request from a Swoole request snapshot.
Swoole’s lowercase server keys are translated to CGI names, the request target gets its query string re-attached, and headers, cookies, query params and uploaded files are carried across. The parsed body is only set when Swoole itself parsed a form body — a JSON or other raw body is left unparsed so downstream payload handling can read it off the stream.
| Parameter | Type | Description |
|---|---|---|
$snapshot | SwooleRequestSnapshot |
Returns ServerRequestInterface