Aerys\Response::setHeader PHP Method

setHeader() public method

This method will replace any existing headers for the specified field.
public setHeader ( string $field, string $value ) : aerys\Response
$field string
$value string
return aerys\Response
    public function setHeader(string $field, string $value) : Response;

Usage Example

Beispiel #1
0
 private function assignCommonHeaders($fileInfo, Response $response)
 {
     $response->setHeader("Accept-Ranges", "bytes");
     $response->setHeader("Cache-Control", "public");
     $response->setHeader("Etag", $fileInfo->etag);
     $response->setHeader("Last-Modified", \gmdate('D, d M Y H:i:s', $fileInfo->mtime) . " GMT");
     $canCache = $this->expiresPeriod > 0;
     if ($canCache && $this->useAggressiveCacheHeaders) {
         $postCheck = (int) ($this->expiresPeriod * $this->aggressiveCacheMultiplier);
         $preCheck = $this->expiresPeriod - $postCheck;
         $expiry = $this->expiresPeriod;
         $value = "post-check={$postCheck}, pre-check={$preCheck}, max-age={$expiry}";
         $response->setHeader("Cache-Control", $value);
     } elseif ($canCache) {
         $expiry = $this->now + $this->expiresPeriod;
         $response->setHeader("Expires", \gmdate('D, d M Y H:i:s', $expiry) . " GMT");
     } else {
         $response->setHeader("Expires", "0");
     }
 }
All Usage Examples Of Aerys\Response::setHeader