Workerman PHP
Workerman માટે PHP સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.
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();
અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.
ચકાસો
curl -sI http://localhost:8080/pixel.gif