Created
March 8, 2018 16:21
-
-
Save tystr/b4c36defa376028f62bf4decaeff411c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Response; | |
use Symfony\Component\HttpFoundation\HeaderBag; | |
use Symfony\Component\HttpFoundation\Response; | |
class TransparentImagePixelResponse extends Response | |
{ | |
/** | |
* @var string | |
*/ | |
const IMAGE_CONTENT = 'R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw=='; | |
/** | |
* @var string | |
*/ | |
const CONTENT_TYPE = 'image/gif'; | |
public function __construct() | |
{ | |
parent::__construct(base64_decode(static::IMAGE_CONTENT)); | |
$this->headers->set('Content-Type', static::CONTENT_TYPE); | |
$this->setPrivate(); | |
$this->headers->addCacheControlDirective('no-cache', true); | |
$this->headers->addCacheControlDirective('must-revalidate', true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment