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


PHP RequestInterface::withAddedHeader方法代碼示例

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


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

示例1:

 function its_middleware_adds_the_header_to_the_request(RequestIdentifierResolver $resolver, RequestInterface $request)
 {
     $identifier = StringRequestIdentifier::fromString('1234');
     $resolver->get()->shouldBeCalled()->willReturn($identifier);
     $request->withAddedHeader('X-Request-Id', '1234')->shouldBeCalled();
     $middlewareFactory = $this->create();
     $middleware = $middlewareFactory(function () {
     });
     $middleware($request, []);
 }
開發者ID:jakzal,項目名稱:Tolerance,代碼行數:10,代碼來源:MiddlewareFactorySpec.php

示例2: withAddedHeader

 /**
  * @param string $header
  * @param string|\string[] $value
  * @return \Psr\Http\Message\MessageInterface
  */
 public function withAddedHeader($header, $value)
 {
     $this->request = $this->request->withAddedHeader($header, $value);
     return $this;
 }
開發者ID:bweston92,項目名稱:expressive-async,代碼行數:10,代碼來源:ServerRequest.php

示例3: signRequest

 /**
  * Sign amazon request.
  *
  * @param RequestInterface $request
  * @param array            $packedCommands Headers generated based on request commands, see
  *                                         packCommands() method for more information.
  * @return RequestInterface
  */
 private function signRequest(RequestInterface $request, array $packedCommands = [])
 {
     $signature = [$request->getMethod(), $request->getHeaderLine('Content-MD5'), $request->getHeaderLine('Content-Type'), $request->getHeaderLine('Date')];
     $normalizedCommands = [];
     foreach ($packedCommands as $command => $value) {
         if (!empty($value)) {
             $normalizedCommands[] = strtolower($command) . ':' . $value;
         }
     }
     if ($normalizedCommands) {
         sort($normalizedCommands);
         $signature[] = join("\n", $normalizedCommands);
     }
     $signature[] = $request->getUri()->getPath();
     return $request->withAddedHeader('Authorization', 'AWS ' . $this->options['accessKey'] . ':' . base64_encode(hash_hmac('sha1', join("\n", $signature), $this->options['secretKey'], true)));
 }
開發者ID:jwdeitch,項目名稱:components,代碼行數:24,代碼來源:AmazonServer.php

示例4: addAuthentificationInfo

 /**
  * @param RequestInterface $request
  *
  * @return RequestInterface
  */
 public function addAuthentificationInfo(RequestInterface $request)
 {
     return $request->withAddedHeader($this->header_name, $this->value);
 }
開發者ID:sc0rp10,項目名稱:rest-client,代碼行數:9,代碼來源:HeaderProvider.php

示例5: withAddedHeader

 public function withAddedHeader($name, $value)
 {
     $new = clone $this;
     $new->request = $this->request->withAddedHeader($name, $value);
     return $new;
 }
開發者ID:deepfreeze,項目名稱:zend-diactoros,代碼行數:6,代碼來源:Request.php


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