示例#1
0
 /**
  * @test
  */
 public function getReturnsNullForNonExistingHeader()
 {
     $headers = new Headers();
     $headers->set('X-Powered-By', 'FLOW3');
     $this->assertFalse($headers->has('X-Empowered-By'));
     $this->assertNull($headers->get('X-Empowered-By'));
 }
示例#2
0
文件: Message.php 项目: nxpthx/FLOW3
 /**
  * Sets the character set for this message.
  *
  * If the content type of this message is a text/* media type, the character
  * set in the respective Content-Type header will be updated by this method.
  *
  * @param string $charset A valid IANA character set identifier
  * @return \TYPO3\FLOW3\Http\Message This message, for method chaining
  * @see http://www.iana.org/assignments/character-sets
  * @api
  */
 public function setCharset($charset)
 {
     $this->charset = $charset;
     if ($this->headers->has('Content-Type')) {
         $contentType = $this->headers->get('Content-Type');
         if (stripos($contentType, 'text/') === 0) {
             $matches = array();
             if (preg_match('/(?P<contenttype>.*); ?charset[^;]+(?P<extra>;.*)?/iu', $contentType, $matches)) {
                 $contentType = $matches['contenttype'];
             }
             $contentType .= '; charset=' . $this->charset . (isset($matches['extra']) ? $matches['extra'] : '');
             $this->setHeader('Content-Type', $contentType, TRUE);
         }
     }
     return $this;
 }