emptygif
Dil: Türkçe

Tüm diller ve framework'ler

FrankenPHP (worker mode) PHP

FrankenPHP (worker mode) için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir PHP örneği.

FrankenPHP (worker mode) PHP

Dosya
index.php
Çalıştır
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();
}

Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.

Kontrol et

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

Resmî site: FrankenPHP (worker mode)

PHP için daha fazlası