本文整理汇总了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, []);
}
示例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;
}
示例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)));
}
示例4: addAuthentificationInfo
/**
* @param RequestInterface $request
*
* @return RequestInterface
*/
public function addAuthentificationInfo(RequestInterface $request)
{
return $request->withAddedHeader($this->header_name, $this->value);
}
示例5: withAddedHeader
public function withAddedHeader($name, $value)
{
$new = clone $this;
$new->request = $this->request->withAddedHeader($name, $value);
return $new;
}