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


PHP RequestInterface::withBody方法代码示例

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


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

示例1: signRequest

 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     $params = Psr7\parse_query($request->getBody());
     $params['Timestamp'] = gmdate('c');
     $params['SignatureVersion'] = '2';
     $params['SignatureMethod'] = 'HmacSHA256';
     $params['AWSAccessKeyId'] = $credentials->getAccessKeyId();
     if ($token = $credentials->getSecurityToken()) {
         $params['SecurityToken'] = $token;
     }
     // build string to sign
     $sign = $request->getMethod() . "\n" . $request->getHeaderLine('Host') . "\n" . '/' . "\n" . $this->getCanonicalizedParameterString($params);
     $params['Signature'] = base64_encode(hash_hmac('sha256', $sign, $credentials->getSecretKey(), true));
     return $request->withBody(Psr7\stream_for(http_build_query($params)));
 }
开发者ID:aws,项目名称:aws-sdk-php-v3-bridge,代码行数:15,代码来源:SignatureV2.php

示例2:

 function it_authenticates_a_request(RequestInterface $request, RequestInterface $newRequest, StreamableInterface $body)
 {
     $body->__toString()->willReturn('{}');
     $body->rewind()->shouldBeCalled();
     $body->isSeekable()->willReturn(true);
     $body->isWritable()->willReturn(true);
     $body->write(json_encode(['email' => 'john.doe@domain.com', 'password' => 'secret']))->shouldBeCalled();
     $request->getBody()->willReturn($body);
     $request->withBody(Argument::type('Psr\\Http\\Message\\StreamableInterface'))->willReturn($newRequest);
     $request = $this->authenticateRequest($request);
     $request->shouldBe($newRequest);
 }
开发者ID:indigophp,项目名称:scaleway,代码行数:12,代码来源:BasicSpec.php

示例3: authenticateRequest

 /**
  * {@inheritdoc}
  */
 public function authenticateRequest(RequestInterface $request)
 {
     $requestBody = $request->getBody();
     $this->ensureBodyRewritable($requestBody);
     $body = (string) $requestBody;
     $body = json_decode($body, true);
     $this->ensureJsonDecodedCorrectly();
     $body['email'] = $this->email;
     $body['password'] = $this->password;
     $requestBody->rewind();
     $requestBody->write(json_encode($body));
     return $request->withBody($requestBody);
 }
开发者ID:indigophp,项目名称:scaleway,代码行数:16,代码来源:Basic.php

示例4: withBody

 /**
  * @param StreamInterface $body
  * @return $this|Request
  */
 public function withBody(StreamInterface $body)
 {
     $this->request = $this->request->withBody($body);
     return $this;
 }
开发者ID:bweston92,项目名称:expressive-async,代码行数:9,代码来源:ServerRequest.php

示例5: withBody

 public function withBody(StreamInterface $body)
 {
     $new = clone $this;
     $new->request = $this->request->withBody($body);
     return $new;
 }
开发者ID:deepfreeze,项目名称:zend-diactoros,代码行数:6,代码来源:Request.php

示例6: setBody

 /**
  * @param string $body The raw request body.
  *
  * @return void
  * @author Mario Mueller
  */
 public function setBody($body)
 {
     $this->guzzleRequest = $this->guzzleRequest->withBody(\GuzzleHttp\Psr7\stream_for($body));
 }
开发者ID:GrizliK1988,项目名称:php-client,代码行数:10,代码来源:GuzzleTransportRequest.php

示例7: getCopyOfRequestWithEmptyBody

 private function getCopyOfRequestWithEmptyBody(RequestInterface $request) : RequestInterface
 {
     $emptyStream = new Stream(fopen('php://temp', 'r+'));
     return $request->withBody($emptyStream);
 }
开发者ID:wadjei,项目名称:request-and-response-helper,代码行数:5,代码来源:RequestAndResponseHelper.php


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