當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。