Example #1
0
 protected function _readHeaderData(&$header)
 {
     $Mime = Mime::getInstance();
     $this->_header = $header;
     $this->_arHeader = Request::parseHeader($header);
     if (array_key_exists('Accept-Ranges', $this->_arHeader) && $this->_arHeader['Accept-Ranges']['VALUES'] == 'bytes') {
         $this->_bCanUseRanges = true;
     }
     if (!empty($this->_arHeader['Content-Type']['VALUE_MAIN'])) {
         $this->_contentType = $this->_arHeader['Content-Type']['VALUE_MAIN'];
         $this->_dwnFileExt = $Mime->getFileExt($this->_contentType, static::DEF_DWN_EXT);
         if (array_key_exists('CHARSET', $this->_arHeader) && $this->_arHeader['CHARSET'] != null) {
             $this->_contentCharset = $this->_arHeader['CHARSET'];
         }
     }
     if (array_key_exists('Content-Disposition', $this->_arHeader) && array_key_exists('OPTIONS', $this->_arHeader['Content-Disposition']) && array_key_exists('filename', $this->_arHeader['Content-Disposition']['OPTIONS']) && !empty($this->_arHeader['Content-Disposition']['OPTIONS']['filename'])) {
         $fileName = $this->_arHeader['Content-Disposition']['OPTIONS']['filename'];
         $dotPos = strrpos($fileName, '.');
         $this->_dwnFileExt = '';
         if ($dotPos !== false) {
             $this->_dwnFileExt = substr($fileName, $dotPos + 1);
         }
         $this->_dwnFileBaseName = substr($fileName, 0, $dotPos);
         Request::fixFileName($this->_dwnFileBaseName);
     } else {
         if ($this->_dwnFileBaseName === null) {
             Request::getFileNameFromUrl($this->_url, $fileExtFromUrl, $baseNameFromUrl);
             if ($this->_dwnFileExt === null && !empty($fileExtFromUrl)) {
                 $this->_dwnFileExt = $fileExtFromUrl;
             }
             if (!empty($baseNameFromUrl)) {
                 $this->_dwnFileBaseName = $baseNameFromUrl;
             } else {
                 $this->_dwnFileBaseName = $this->_dwnName;
             }
         }
     }
     if (array_key_exists('Content-Length', $this->_arHeader)) {
         $this->_contentExpectedSize = $this->_arHeader['Content-Length']['VALUE'];
         if ($this->_rangeFrom < 1) {
             $this->_fileExpectedSize = $this->_contentExpectedSize;
         }
     }
     $this->_responseStatusCode = $this->_arHeader['STATUS']['CODE'];
     $this->_responseStatusMsg = $this->_arHeader['STATUS']['MESSAGE'];
 }