FrankenPHP (worker mode) PHP
FrankenPHP (worker mode) માટે PHP સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.
FrankenPHP (worker mode) 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)