Slim PHP
Slim کے لیے PHP کا اسنیپٹ جو /pixel.gif کی درخواستوں کا جواب خالی GIF سے دیتا ہے، جسے اسٹارٹ اپ پر ایک بار ڈیکوڈ کیا جاتا ہے۔
Slim PHP
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
require __DIR__ . '/vendor/autoload.php';
$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
$app = AppFactory::create();
$app->get('/pixel.gif', function (Request $request, Response $response) use ($gif) {
$response->getBody()->write($gif);
return $response
->withHeader('Content-Type', 'image/gif')
->withHeader('Content-Length', (string) strlen($gif))
->withHeader('Cache-Control', 'no-store');
});
$app->run();
ہم نے یہ اسنیپٹ چلایا اور اس کی لوٹائی ہوئی بائٹس کا موازنہ کیا۔
جانچیں
curl -sI http://localhost:8080/pixel.gif