當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HeaderBag::set方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\HeaderBag::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP HeaderBag::set方法的具體用法?PHP HeaderBag::set怎麽用?PHP HeaderBag::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\HeaderBag的用法示例。


在下文中一共展示了HeaderBag::set方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fixAuthHeader

 /**
  * PHP does not include HTTP_AUTHORIZATION in the $_SERVER array, so this header is missing.
  * We retrieve it from apache_request_headers()
  *
  * @param HeaderBag $headers
  */
 protected function fixAuthHeader(HeaderBag $headers)
 {
     if (!$headers->has('Authorization') && function_exists('apache_request_headers')) {
         $all = apache_request_headers();
         if (isset($all['Authorization'])) {
             $headers->set('Authorization', $all['Authorization']);
         }
         if (isset($all['authorization'])) {
             $headers->set('Authorization', $all['authorization']);
         }
     }
 }
開發者ID:profcab,項目名稱:ilios,代碼行數:18,代碼來源:AuthenticationHeader.php

示例2: fixAuthHeader

 /**
  * PHP does not include HTTP_AUTHORIZATION in the $_SERVER array, so this header is missing.
  * We retrieve it from apache_request_headers()
  *
  * @see https://github.com/symfony/symfony/issues/7170
  *
  * @param HeaderBag $headers
  */
 private static function fixAuthHeader(\Symfony\Component\HttpFoundation\HeaderBag $headers)
 {
     if (!$headers->has('Authorization') && function_exists('apache_request_headers')) {
         $all = apache_request_headers();
         if (isset($all['Authorization'])) {
             $headers->set('Authorization', $all['Authorization']);
         }
     }
 }
開發者ID:vzailskas,項目名稱:oauth2-server-httpfoundation-bridge,代碼行數:17,代碼來源:Request.php

示例3: setHeaders

 /**
  * @param array $headers
  */
 public function setHeaders(array $headers)
 {
     foreach ($headers as $name => $value) {
         if ($this->metadata->isPrefixedKey($name)) {
             $this->metadata->set($name, $value);
         } else {
             // make sure we store an array
             $this->headers->set($name, (array) $value);
         }
     }
 }
開發者ID:treehouselabs,項目名稱:swift-client,代碼行數:14,代碼來源:Container.php

示例4: setRedirect

 /**
  * Modifies the response so that it conforms to the rules defined for a redirect status code.
  *
  * @see http://tools.ietf.org/html/rfc2616#section-10.3.5
  */
 public function setRedirect($url, $status = 302)
 {
     if (empty($url)) {
         throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
     }
     $this->setStatusCode($status);
     if (!$this->isRedirect()) {
         throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
     }
     $this->headers->set('Location', $url);
     $this->setContent(sprintf('<html><head><meta http-equiv="refresh" content="1;url=%s"/></head></html>', htmlspecialchars($url, ENT_QUOTES)));
 }
開發者ID:netixpro,項目名稱:symfony,代碼行數:17,代碼來源:Response.php

示例5: testContains

 /**
  * @covers Symfony\Component\HttpFoundation\HeaderBag::contains
  */
 public function testContains()
 {
     $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz'));
     $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value');
     $this->assertTrue($bag->contains('fuzz', 'bizz'), '->contains second value');
     $this->assertFalse($bag->contains('nope', 'nope'), '->contains unknown value');
     $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value');
     // Multiple values
     $bag->set('foo', 'bor', false);
     $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value');
     $this->assertTrue($bag->contains('foo', 'bor'), '->contains second value');
     $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value');
 }
開發者ID:vieiragabriel,項目名稱:moodle-block_gchat,代碼行數:16,代碼來源:HeaderBagTest.php

示例6: setVary

 /**
  * Sets the Vary header.
  *
  * @param string|array $headers
  * @param Boolean      $replace Whether to replace the actual value of not (true by default)
  */
 public function setVary($headers, $replace = true)
 {
     $this->headers->set('Vary', $headers, $replace);
 }
開發者ID:rsky,項目名稱:symfony,代碼行數:10,代碼來源:Response.php

示例7: set

 /**
  * Sets a header by name.
  *
  * @param string  $key
  * @param mixed   $values
  * @param Boolean $replace
  */
 public function set($key, $values, $replace = true)
 {
     parent::set($key, $values, $replace);
     $this->updateRequest();
 }
開發者ID:hardwork2015,項目名稱:cdp,代碼行數:12,代碼來源:HeaderBag.php

示例8: enforceNoCache

 /**
  * @param HeaderBag $headers
  */
 private function enforceNoCache(HeaderBag $headers)
 {
     $headers->set('cache-control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
     $headers->set('Pragma', 'no-cache', false);
 }
開發者ID:supportyard,項目名稱:framework-bundle,代碼行數:8,代碼來源:ResponseDecoratorListener.php

示例9: getContainerRenderActionCached

 protected function getContainerRenderActionCached()
 {
     $headerBag = new HeaderBag();
     $headerBag->set('If-Modified-Since', false);
     $requestMock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->disableOriginalConstructor()->getMock();
     $requestMock->expects($this->at(0))->method('get')->will($this->returnValue('test.txt'));
     $requestMock->expects($this->at(1))->method('get')->will($this->returnValue('cached_hash'));
     $requestMock->expects($this->any())->method('isMethodSafe')->will($this->returnValue(true));
     $requestMock->expects($this->any())->method('getMethod')->will($this->returnValue('GET'));
     $requestMock->expects($this->any())->method('getEtags')->will($this->returnValue(array('"cached_hash"')));
     $requestMock->headers = $headerBag;
     $container = new Container();
     $container->set('request', $requestMock);
     return $container;
 }
開發者ID:thrace-project,項目名稱:media-bundle,代碼行數:15,代碼來源:FileControllerTest.php

示例10: set

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function set($key, $values, $replace = true)
 {
     parent::set($key, $values, $replace);
     $uniqueKey = strtr(strtolower($key), '_', '-');
     $this->headerNames[$uniqueKey] = $key;
 }
開發者ID:euskadi31,項目名稱:spore,代碼行數:11,代碼來源:HeaderBag.php

示例11: setLastModifiedDate

 /**
  * @param \DateTime $lastModified
  */
 public function setLastModifiedDate(\DateTime $lastModified)
 {
     $this->headers->set('Last-Modified', $lastModified->format(DATE_RFC2822));
 }
開發者ID:treehouselabs,項目名稱:swift-client,代碼行數:7,代碼來源:Object.php

示例12: fixHeaderBag

 /**
  * @param HeaderBag $headers
  */
 public function fixHeaderBag(HeaderBag $headers)
 {
     if (!$headers->has('Authorization')) {
         $headers->set('Authorization', $this->getAuthorizationHeader());
     }
 }
開發者ID:alcalyn,項目名稱:authorization-header-fix,代碼行數:9,代碼來源:AuthorizationHeaderFixListener.php


注:本文中的Symfony\Component\HttpFoundation\HeaderBag::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。