mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 07:20:18 +08:00
Response WIP
This commit is contained in:
@@ -28,6 +28,21 @@ class Response extends \yii\base\Response
|
||||
*/
|
||||
public $ajaxRedirectCode = 278;
|
||||
|
||||
private $_headers;
|
||||
|
||||
/**
|
||||
* Returns the header collection.
|
||||
* The header collection contains the currently registered HTTP headers.
|
||||
* @return HeaderCollection the header collection
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
if ($this->_headers === null) {
|
||||
$this->_headers = new HeaderCollection;
|
||||
}
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a file to user.
|
||||
* @param string $fileName file name
|
||||
@@ -51,7 +66,7 @@ class Response extends \yii\base\Response
|
||||
|
||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||
// client sent us a multibyte range, can not hold this one for now
|
||||
if (strpos($_SERVER['HTTP_RANGE'],',') !== false) {
|
||||
if (strpos($_SERVER['HTTP_RANGE'], ',') !== false) {
|
||||
header("Content-Range: bytes $contentStart-$contentEnd/$fileSize");
|
||||
throw new HttpException(416, 'Requested Range Not Satisfiable');
|
||||
}
|
||||
@@ -75,7 +90,7 @@ class Response extends \yii\base\Response
|
||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
*/
|
||||
// End bytes can not be larger than $end.
|
||||
$contentEnd = ($contentEnd > $fileSize) ? $fileSize -1 : $contentEnd;
|
||||
$contentEnd = ($contentEnd > $fileSize) ? $fileSize - 1 : $contentEnd;
|
||||
|
||||
// Validate the requested range and return an error if it's not correct.
|
||||
$wrongContentStart = ($contentStart > $contentEnd || $contentStart > $fileSize - 1 || $contentStart < 0);
|
||||
|
||||
Reference in New Issue
Block a user