当前位置: 首页>>代码示例>>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;未经允许,请勿转载。