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