ReactPHP PHP
ReactPHP માટે PHP સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.
ReactPHP PHP
<?php
use Psr\Http\Message\ServerRequestInterface;
use React\Http\HttpServer;
use React\Http\Message\Response;
use React\Socket\SocketServer;
require __DIR__ . '/vendor/autoload.php';
$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
$http = new HttpServer(function (ServerRequestInterface $request) use ($gif) {
if ($request->getMethod() !== 'GET' || $request->getUri()->getPath() !== '/pixel.gif') {
return new Response(Response::STATUS_NOT_FOUND);
}
return new Response(Response::STATUS_OK, [
'Content-Type' => 'image/gif',
'Cache-Control' => 'no-store',
], $gif);
});
$http->listen(new SocketServer('0.0.0.0:8080'));
અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.
ચકાસો
curl -sI http://localhost:8080/pixel.gif