emptygif
భాష: తెలుగు

అన్ని భాషలు, ఫ్రేమ్‌వర్క్‌లు

FrankenPHP (worker mode) PHP

/pixel.gif కు వచ్చే రిక్వెస్ట్‌లకు empty GIF తో జవాబిచ్చే, FrankenPHP (worker mode) కోసం PHP స్నిపెట్. GIF స్టార్టప్‌లో ఒక్కసారే డీకోడ్ అవుతుంది.

FrankenPHP (worker mode) PHP

ఫైల్
index.php
రన్
frankenphp php-server --listen :8080 --worker index.php
<?php

// Worker script: booted once, then handles requests in a loop.
ignore_user_abort(true);

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

$handler = static function () use ($gif): void {
    if (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) !== '/pixel.gif') {
        http_response_code(404);
        return;
    }
    header('Content-Type: image/gif');
    header('Content-Length: ' . strlen($gif));
    header('Cache-Control: no-store');
    echo $gif;
};

while (frankenphp_handle_request($handler)) {
    gc_collect_cycles();
}

మేము ఈ స్నిపెట్‌ను రన్ చేసి, అది తిరిగి ఇచ్చిన బైట్‌లను పోల్చి చూశాం.

చెక్ చేయండి

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

అధికారిక సైట్: FrankenPHP (worker mode)

PHP లో మరిన్ని