当前位置: 首页>>代码示例>>PHP>>正文


PHP ServerRequestInterface::withHeader方法代码示例

本文整理汇总了PHP中Psr\Http\Message\ServerRequestInterface::withHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestInterface::withHeader方法的具体用法?PHP ServerRequestInterface::withHeader怎么用?PHP ServerRequestInterface::withHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\ServerRequestInterface的用法示例。


在下文中一共展示了ServerRequestInterface::withHeader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: willReturnNullWhenMatchWasNotFound

 /**
  * @test
  */
 public function willReturnNullWhenMatchWasNotFound()
 {
     $this->request = $this->request->withHeader('Accept', 'text/html');
     $this->negotiator->expects($this->once())->method('getBest')->will($this->returnValue(null));
     $bestMatch = $this->manager->getBestMatch($this->request);
     $this->assertNull($bestMatch);
 }
开发者ID:bitexpert,项目名称:adrenaline,代码行数:10,代码来源:ContentNegotiationManagerUnitTest.php

示例2: __invoke

 public function __invoke(ServerRequestInterface $request)
 {
     $forwardedFor = array();
     if ($this->trustPreviousReverseProxies && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $forwardedFor[] = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
     }
     $forwardedFor[] = $_SERVER['REMOTE_ADDR'];
     return $request->withHeader("X-Forwarded-For", implode(",", $forwardedFor));
 }
开发者ID:jvelo,项目名称:proxy-factory,代码行数:9,代码来源:XForwardedForRequestFilter.php

示例3: withHeader

 /**
  * {@inheritdoc}
  */
 public function withHeader($name, $value)
 {
     return new static($this->wrapped->withHeader($name, $value));
 }
开发者ID:Mosaic,项目名称:Mosaic,代码行数:7,代码来源:Request.php

示例4: withHeader

 /**
  * {@inheritDoc}
  */
 public function withHeader($name, $value)
 {
     return new self($this->app, $this->psrRequest->withHeader($name, $value));
 }
开发者ID:tonis-io,项目名称:tonis,代码行数:7,代码来源:Request.php

示例5: assertRequestHeader

 /**
  * Assert request header and we only accept application/json or ajax request.
  *
  * @param  \Psr\Http\Message\ServerRequestInterface $request
  * @return \Psr\Http\Message\ServerRequestInterface
  * @throws \InvalidArgumentException If Request Accept header not application/json.
  */
 protected function assertRequestHeader(Request $request)
 {
     // If it's an AJAX request, return as is
     if ($request->getHeaderLine('X-Requested-With') == 'XMLHttpRequest') {
         return $request;
     }
     // Otherwise, split the Accept header
     $accepts = explode(',', $request->getHeaderLine('Accept'));
     // Make sure it's accept application/json
     if (in_array('application/json', $accepts)) {
         return $request->withHeader('X-Requested-With', 'XMLHttpRequest');
     }
     // Otherwise, throw it
     throw new InvalidArgumentException('Invalid request');
 }
开发者ID:projek-xyz,项目名称:id-nik,代码行数:22,代码来源:Nik.php

示例6: withHeader

 /**
  * Proxy to ServerRequestInterface::withHeader()
  *
  * {@inheritdoc}
  */
 public function withHeader($header, $value)
 {
     $new = $this->psrRequest->withHeader($header, $value);
     return new self($new, $this->originalRequest);
 }
开发者ID:michaelmoussa,项目名称:zend-stratigility,代码行数:10,代码来源:Request.php

示例7: withHeader

 /**
  * @inheritDoc
  */
 public function withHeader($name, $value)
 {
     $self = clone $this;
     $self->serverRequest = $this->serverRequest->withHeader($name, $value);
     return $self;
 }
开发者ID:superbull,项目名称:super,代码行数:9,代码来源:Request.php


注:本文中的Psr\Http\Message\ServerRequestInterface::withHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。