From 0b8d239ad3ed34ef145c463e76065c774d96b4dd Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 11 Jun 2013 16:05:25 -0400 Subject: [PATCH] Renamed HeaderCollection::addDefault to setDefault. --- framework/yii/web/HeaderCollection.php | 4 ++-- framework/yii/web/Response.php | 38 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/framework/yii/web/HeaderCollection.php b/framework/yii/web/HeaderCollection.php index aa3e01f..872a997 100644 --- a/framework/yii/web/HeaderCollection.php +++ b/framework/yii/web/HeaderCollection.php @@ -104,13 +104,13 @@ class HeaderCollection extends Object implements \IteratorAggregate, \ArrayAcces } /** - * Adds a new header only if it does not exist yet. + * Sets a new header only if it does not exist yet. * If there is already a header with the same name, the new one will be ignored. * @param string $name the name of the header * @param string $value the value of the header * @return HeaderCollection the collection object itself */ - public function addDefault($name, $value) + public function setDefault($name, $value) { $name = strtolower($name); if (empty($this->_headers[$name])) { diff --git a/framework/yii/web/Response.php b/framework/yii/web/Response.php index 3349d61..00721ac 100644 --- a/framework/yii/web/Response.php +++ b/framework/yii/web/Response.php @@ -309,14 +309,14 @@ class Response extends \yii\base\Response throw new HttpException(416, Yii::t('yii', 'Requested range not satisfiable')); } - $headers->addDefault('Pragma', 'public') - ->addDefault('Accept-Ranges', 'bytes') - ->addDefault('Expires', '0') - ->addDefault('Content-Type', $mimeType) - ->addDefault('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') - ->addDefault('Content-Transfer-Encoding', 'binary') - ->addDefault('Content-Length', StringHelper::strlen($content)) - ->addDefault('Content-Disposition', "attachment; filename=\"$attachmentName\""); + $headers->setDefault('Pragma', 'public') + ->setDefault('Accept-Ranges', 'bytes') + ->setDefault('Expires', '0') + ->setDefault('Content-Type', $mimeType) + ->setDefault('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') + ->setDefault('Content-Transfer-Encoding', 'binary') + ->setDefault('Content-Length', StringHelper::strlen($content)) + ->setDefault('Content-Disposition', "attachment; filename=\"$attachmentName\""); list($begin, $end) = $range; if ($begin !=0 || $end != $contentLength - 1) { @@ -360,14 +360,14 @@ class Response extends \yii\base\Response $length = $end - $begin + 1; - $headers->addDefault('Pragma', 'public') - ->addDefault('Accept-Ranges', 'bytes') - ->addDefault('Expires', '0') - ->addDefault('Content-Type', $mimeType) - ->addDefault('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') - ->addDefault('Content-Transfer-Encoding', 'binary') - ->addDefault('Content-Length', $length) - ->addDefault('Content-Disposition', "attachment; filename=\"$attachmentName\""); + $headers->setDefault('Pragma', 'public') + ->setDefault('Accept-Ranges', 'bytes') + ->setDefault('Expires', '0') + ->setDefault('Content-Type', $mimeType) + ->setDefault('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') + ->setDefault('Content-Transfer-Encoding', 'binary') + ->setDefault('Content-Length', $length) + ->setDefault('Content-Disposition', "attachment; filename=\"$attachmentName\""); $this->send(); @@ -478,9 +478,9 @@ class Response extends \yii\base\Response } $this->getHeaders() - ->addDefault($xHeader, $filePath) - ->addDefault('Content-Type', $mimeType) - ->addDefault('Content-Disposition', "attachment; filename=\"$attachmentName\""); + ->setDefault($xHeader, $filePath) + ->setDefault('Content-Type', $mimeType) + ->setDefault('Content-Disposition', "attachment; filename=\"$attachmentName\""); $this->send(); }