emptygif
Idioma: Português

Todas as linguagens e frameworks

Plain PHP (php-fpm, mod_php, php -S) PHP

Um snippet em PHP para Plain PHP (php-fpm, mod_php, php -S) que responde às requisições para /pixel.gif com o GIF vazio, decodificado uma única vez na inicialização.

Plain PHP (php-fpm, mod_php, php -S) PHP

Arquivo
index.php
Executar
php -S 0.0.0.0:8080 index.php
<?php

// Front controller: works under php-fpm, Apache mod_php or the built-in server.
if (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) !== '/pixel.gif') {
    http_response_code(404);
    return;
}

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

header('Content-Type: image/gif');
header('Content-Length: ' . strlen($gif));
header('Cache-Control: no-store');
echo $gif;

Executamos este snippet e comparamos os bytes que ele retornou.

Verificar

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

Site oficial: Plain PHP (php-fpm, mod_php, php -S)

Mais em PHP