Esempio n. 1
0
 /**
  */
 public function __get($name)
 {
     switch ($name) {
         case 'params':
             $params = new Horde_Support_CaseInsensitiveArray(parent::__get($name));
             foreach ($params as $key => $val) {
                 if (!isset($this[$key])) {
                     unset($params[$key]);
                 }
             }
             return $params->getArrayCopy();
         case 'ptype':
             $val = $this->value;
             return substr($val, 0, strpos($val, '/'));
         case 'stype':
             $val = $this->value;
             return substr($val, strpos($val, '/') + 1);
         case 'type_charset':
             $val = $this->value;
             foreach ($this->_escapeParams(array_filter(array('charset' => $this['charset']))) as $k2 => $v2) {
                 $val .= '; ' . $k2 . '=' . $v2;
             }
             return $val;
     }
     return parent::__get($name);
 }
Esempio n. 2
0
 /**
  */
 public function __get($name)
 {
     switch ($name) {
         case 'full_value':
             $tmp = $this->value;
             foreach ($this->_escapeParams($this->params) as $key => $val) {
                 $tmp .= '; ' . $key . '=' . $val;
             }
             return $tmp;
         case 'params':
             return $this->_params->getArrayCopy();
     }
     return parent::__get($name);
 }
Esempio n. 3
0
File: Base.php Progetto: horde/horde
 /**
  * Parses an array of response headers, mindful of line continuations, etc.
  *
  * @param array $headers
  *
  * @return array
  */
 protected function _parseHeaders($headers)
 {
     if (!is_array($headers)) {
         $headers = preg_split("/\r?\n/", $headers);
     }
     $this->_headers = new Horde_Support_CaseInsensitiveArray();
     $lastHeader = null;
     foreach ($headers as $headerLine) {
         // stream_get_meta returns all headers generated while processing
         // a request, including ones for redirects before an eventually
         // successful request. We just want the last one, so whenever we
         // hit a new HTTP header, throw out anything parsed previously and
         // start over.
         if (preg_match('/^HTTP\\/(\\d.\\d) (\\d{3})/', $headerLine, $httpMatches)) {
             $this->httpVersion = $httpMatches[1];
             $this->code = (int) $httpMatches[2];
             $this->_headers = new Horde_Support_CaseInsensitiveArray();
             $lastHeader = null;
         }
         $headerLine = trim($headerLine, "\r\n");
         if ($headerLine == '') {
             break;
         }
         if (preg_match('|^([\\w-]+):\\s+(.+)|', $headerLine, $m)) {
             $headerName = $m[1];
             $headerValue = $m[2];
             if ($tmp = $this->_headers[$headerName]) {
                 if (!is_array($tmp)) {
                     $tmp = array($tmp);
                 }
                 $tmp[] = $headerValue;
                 $headerValue = $tmp;
             }
             $this->_headers[$headerName] = $headerValue;
             $lastHeader = $headerName;
         } elseif (preg_match("|^\\s+(.+)\$|", $headerLine, $m) && !is_null($lastHeader)) {
             if (is_array($this->_headers[$lastHeader])) {
                 $tmp = $this->_headers[$lastHeader];
                 end($tmp);
                 $tmp[key($tmp)] .= $m[1];
                 $this->_headers[$lastHeader] = $tmp;
             } else {
                 $this->_headers[$lastHeader] .= $m[1];
             }
         }
     }
     $this->headers = array_change_key_case($this->_headers->getArrayCopy());
 }
Esempio n. 4
0
 /**
  * Serialization.
  *
  * @return string  Serialized data.
  */
 public function serialize()
 {
     $data = array(self::VERSION, $this->_headers->getArrayCopy(), $this->_eol);
     return serialize($data);
 }
Esempio n. 5
0
 /**
  * Get all parameters from the Content-Type header.
  *
  * @return array  An array of all the parameters
  *                Returns the empty array if no parameters set.
  */
 public function getAllContentTypeParameters()
 {
     return $this->_contentTypeParams->getArrayCopy();
 }