コード例 #1
0
ファイル: Message.php プロジェクト: nxpthx/FLOW3
 /**
  * Sets the specified HTTP header
  *
  * DateTime objects will be converted to a string representation internally but
  * will be returned as DateTime objects on calling getHeader().
  *
  * Please note that dates are normalized to GMT internally, so that getHeader() will return
  * the same point in time, but not necessarily in the same timezone, if it was not
  * GMT previously. GMT is used synonymously with UTC as per RFC 2616 3.3.1.
  *
  * @param string $name Name of the header, for example "Location", "Content-Description" etc.
  * @param array|string|\DateTime $values An array of values or a single value for the specified header field
  * @param boolean $replaceExistingHeader If a header with the same name should be replaced. Default is TRUE.
  * @return \TYPO3\FLOW3\Http\Message This message, for method chaining
  * @api
  */
 public function setHeader($name, $values, $replaceExistingHeader = TRUE)
 {
     switch ($name) {
         case 'Content-Type':
             if (stripos($values, 'charset') === FALSE && stripos($values, 'text/') === 0) {
                 $values .= '; charset=' . $this->charset;
             }
             break;
     }
     $this->headers->set($name, $values, $replaceExistingHeader);
     return $this;
 }
コード例 #2
0
ファイル: HeadersTest.php プロジェクト: nxpthx/FLOW3
 /**
  * @test
  */
 public function setOverridesAnyPreviouslyDefinedCacheControlDirectives()
 {
     $headers = new Headers();
     $headers->setCacheControlDirective('public');
     $headers->set('Cache-Control', 'max-age=600, must-revalidate');
     $this->assertEquals('max-age=600, must-revalidate', $headers->get('Cache-Control'));
 }