Workerman PHP
Kipande cha PHP kwa Workerman kinachojibu maombi ya /pixel.gif kwa empty GIF, ambayo husimbuliwa (decode) mara moja programu inapoanza.
Workerman PHP
<?php
use Workerman\Connection\TcpConnection;
use Workerman\Protocols\Http\Request;
use Workerman\Protocols\Http\Response;
use Workerman\Worker;
require __DIR__ . '/vendor/autoload.php';
$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
$worker = new Worker('http://0.0.0.0:8080');
$worker->onMessage = function (TcpConnection $connection, Request $request) use ($gif) {
if ($request->path() !== '/pixel.gif') {
$connection->send(new Response(404));
return;
}
$connection->send(new Response(200, [
'Content-Type' => 'image/gif',
'Cache-Control' => 'no-store',
], $gif));
};
Worker::runAll();
Tuliendesha kipande hiki na kulinganisha baiti kilizorudisha.
Kagua
curl -sI http://localhost:8080/pixel.gif