emptygif
भाषा: हिन्दी

सभी भाषाएँ और फ़्रेमवर्क

ReactPHP PHP

ReactPHP के लिए PHP स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।

ReactPHP PHP

इंस्टॉल
composer require react/http
फ़ाइल
server.php
चलाएँ
php server.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

आधिकारिक साइट: ReactPHP

PHP में और