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

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

Swoole PHP

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

Swoole PHP

इंस्टॉल
pecl install swoole
फ़ाइल
server.php
चलाएँ
php server.php
<?php

use Swoole\Http\Request;
use Swoole\Http\Response;
use Swoole\Http\Server;

$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

$server = new Server('0.0.0.0', 8080);
$server->set(['http_compression' => false]); // gzip only makes a tiny GIF bigger

$server->on('request', function (Request $request, Response $response) use ($gif) {
    if ($request->server['request_uri'] !== '/pixel.gif') {
        $response->status(404);
        $response->end();
        return;
    }
    $response->header('Content-Type', 'image/gif');
    $response->header('Cache-Control', 'no-store');
    $response->end($gif);
});

$server->start();

हमने यह स्निपेट चलाया और इसके लौटाए बाइट्स की तुलना की।

जाँचें

curl -sI http://localhost:8080/pixel.gif

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

PHP में और