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


PHP RequestInterface::getResponse方法代码示例

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


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

示例1: writeResponseBody

 /**
  * Write data to the response body of a request
  *
  * @param resource $curl  Curl handle
  * @param string   $write Data that was received
  *
  * @return int
  */
 public function writeResponseBody($curl, $write)
 {
     if ($this->emitIo) {
         $this->request->dispatch('curl.callback.write', array('request' => $this->request, 'write' => $write));
     }
     return $this->request->getResponse()->getBody()->write($write);
 }
开发者ID:KANU82,项目名称:guzzle,代码行数:15,代码来源:RequestMediator.php

示例2: add

 /**
  * Add a request to the history
  *
  * @param RequestInterface $request  Request to add
  * @param Response         $response Response of the request
  *
  * @return HistoryPlugin
  */
 public function add(RequestInterface $request, Response $response = null)
 {
     if (!$response && $request->getResponse()) {
         $response = $request->getResponse();
     }
     $this->transactions[] = array('request' => $request, 'response' => $response);
     if (count($this->transactions) > $this->getlimit()) {
         array_shift($this->transactions);
     }
     return $this;
 }
开发者ID:adrianoaguiar,项目名称:magento-elasticsearch-module,代码行数:19,代码来源:HistoryPlugin.php

示例3: writeResponseBody

 /**
  * Write data to the response body of a request
  *
  * @param resource $curl  Curl handle
  * @param string   $write Data that was received
  *
  * @return int
  */
 public function writeResponseBody($curl, $write)
 {
     if ($this->emitIo) {
         $this->request->dispatch('curl.callback.write', array('request' => $this->request, 'write' => $write));
     }
     if ($response = $this->request->getResponse()) {
         return $response->getBody()->write($write);
     } else {
         // Unexpected data received before response headers - abort transfer
         return 0;
     }
 }
开发者ID:adrianoaguiar,项目名称:magento-elasticsearch-module,代码行数:20,代码来源:RequestMediator.php

示例4: __construct

 /**
  * Create a new response object from a Clickatell request and response.
  *
  * @param \Guzzle\Http\Message\RequestInterface $request The request object 
  * associated with the response.
  * @throws \UnexpectedValueException when the request does not have a response.
  */
 public function __construct($request)
 {
     $response = $request->getResponse();
     if (!$response) {
         throw new \UnexpectedValueException('Request must have have a response.');
     }
     $this->request = $request;
     $this->parsedResponse = $this->parseBody($response->getBody());
 }
开发者ID:bluedogtraining,项目名称:guzzle-clickatell,代码行数:16,代码来源:AbstractResponse.php

示例5: add

 /**
  * Add a request to the history
  *
  * @param RequestInterface $request Request to add
  *
  * @return HistoryPlugin
  */
 public function add(RequestInterface $request)
 {
     if ($request->getResponse()) {
         $this->requests[] = $request;
         if (count($this->requests) > $this->getlimit()) {
             array_shift($this->requests);
         }
     }
     return $this;
 }
开发者ID:vieiragabriel,项目名称:moodle-block_gchat,代码行数:17,代码来源:HistoryPlugin.php

示例6: sendRequest

 /**
  * Sends a request
  *
  * @param RequestInterface $request
  * @return Response
  * @throws ForbiddenException
  * @throws MetricaException
  */
 protected function sendRequest(RequestInterface $request)
 {
     try {
         $request->setHeader('User-Agent', $this->getUserAgent());
         $response = $request->send();
     } catch (ClientErrorResponseException $ex) {
         $result = $request->getResponse();
         $code = $result->getStatusCode();
         $message = $result->getReasonPhrase();
         if ($code === 403) {
             throw new ForbiddenException($message);
         }
         throw new MetricaException('Service responded with error code: "' . $code . '" and message: "' . $message . '"');
     }
     return $response;
 }
开发者ID:silverslice,项目名称:yandex-php-library,代码行数:24,代码来源:MetricaClient.php

示例7: updateRequestFromTransfer

 /**
  * Update a request based on the log messages of the CurlHandle
  *
  * @param RequestInterface $request Request to update
  */
 public function updateRequestFromTransfer(RequestInterface $request)
 {
     if (!$request->getResponse()) {
         return;
     }
     // Update the transfer stats of the response
     $request->getResponse()->setInfo($this->getInfo());
     if (!($log = $this->getStderr(true))) {
         return;
     }
     // Parse the cURL stderr output for outgoing requests
     $headers = '';
     fseek($log, 0);
     while (($line = fgets($log)) !== false) {
         if ($line && $line[0] == '>') {
             $headers = substr(trim($line), 2) . "\r\n";
             while (($line = fgets($log)) !== false) {
                 if ($line[0] == '*' || $line[0] == '<') {
                     break;
                 } else {
                     $headers .= trim($line) . "\r\n";
                 }
             }
         }
     }
     // Add request headers to the request exactly as they were sent
     if ($headers) {
         $parsed = ParserRegistry::getInstance()->getParser('message')->parseRequest($headers);
         if (!empty($parsed['headers'])) {
             $request->setHeaders(array());
             foreach ($parsed['headers'] as $name => $value) {
                 $request->setHeader($name, $value);
             }
         }
         if (!empty($parsed['version'])) {
             $request->setProtocolVersion($parsed['version']);
         }
     }
 }
开发者ID:TechArea,项目名称:core,代码行数:44,代码来源:CurlHandle.php

示例8: validateResponseWasSet

 /**
  * @link https://github.com/guzzle/guzzle/issues/710
  */
 private function validateResponseWasSet(RequestInterface $request)
 {
     if ($request->getResponse()) {
         return true;
     }
     $body = $request instanceof EntityEnclosingRequestInterface ? $request->getBody() : null;
     if (!$body) {
         $rex = new RequestException('No response was received for a request with no body. This' . ' could mean that you are saturating your network.');
         $rex->setRequest($request);
         $this->removeErroredRequest($request, $rex);
     } elseif (!$body->isSeekable() || !$body->seek(0)) {
         // Nothing we can do with this. Sorry!
         $rex = new RequestException('The connection was unexpectedly closed. The request would' . ' have been retried, but attempting to rewind the' . ' request body failed.');
         $rex->setRequest($request);
         $this->removeErroredRequest($request, $rex);
     } else {
         $this->remove($request);
         // Add the request back to the batch to retry automatically.
         $this->requests[] = $request;
         $this->addHandle($request);
     }
     return false;
 }
开发者ID:sharpspring,项目名称:guzzle3,代码行数:26,代码来源:CurlMulti.php

示例9: collectTime

 /**
  * Collect time for a Guzzle request
  *
  * @param Guzzle\Http\Message\RequestInterface $request
  *
  * @return array
  */
 private function collectTime(GuzzleRequestInterface $request)
 {
     $response = $request->getResponse();
     return array('total' => $response->getInfo('total_time'), 'connection' => $response->getInfo('connect_time'));
 }
开发者ID:ma-si,项目名称:GuzzleBundle,代码行数:12,代码来源:GuzzleDataCollector.php

示例10: sendRequest

 /**
  * @param $request RequestInterface
  * @return mixed
  * @throws Exception
  */
 private function sendRequest(RequestInterface $request)
 {
     try {
         $request->send();
     } catch (ClientErrorResponseException $e) {
         $data = json_decode($request->getResponse()->getBody(true), true);
         if ($e->getResponse()->getStatusCode() == 404) {
             throw new CredentialsNotFoundException($data["message"], null, $e);
         } else {
             throw new Exception('Error from Provisioning API: ' . $data["message"], null, $e);
         }
     } catch (BadResponseException $e) {
         throw new Exception('Error receiving response from Provisioning API', null, $e);
     }
     $result = $this->parseResponse($request->getResponse()->getBody(true));
     return $result;
 }
开发者ID:keboola,项目名称:provisioning-client,代码行数:22,代码来源:Client.php

示例11: throwTooManyRedirectsException

 /**
  * Throw a too many redirects exception for a request
  *
  * @param RequestInterface $request Request
  * @throws TooManyRedirectsException when too many redirects have been issued
  */
 protected function throwTooManyRedirectsException(RequestInterface $request)
 {
     $lines = array();
     $response = $request->getResponse();
     do {
         $lines[] = '> ' . $response->getRequest()->getRawHeaders() . "\n\n< " . $response->getRawHeaders();
         $response = $response->getPreviousResponse();
     } while ($response);
     throw new TooManyRedirectsException("Too many redirects were issued for this transaction:\n" . implode("* Sending redirect request\n", array_reverse($lines)));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:16,代码来源:RedirectPlugin.php

示例12: sendRequest

 /**
  * @param RequestInterface $request
  * @return array
  * @throws CommunicationError
  * @throws ExpiredAuthRequestError
  * @throws InvalidCredentialsError
  * @throws InvalidRequestError
  * @throws InvalidResponseError
  * @throws LaunchKeyEngineError
  * @throws NoPairedDevicesError
  * @throws NoSuchUserError
  * @throws RateLimitExceededError
  */
 private function sendRequest(RequestInterface $request)
 {
     try {
         $response = $request->send();
         $this->debugLog("Response received", array("response" => $response->getMessage()));
     } catch (ClientErrorResponseException $e) {
         $message = $e->getMessage();
         $code = $e->getCode();
         try {
             $data = $this->jsonDecodeData($request->getResponse()->getBody());
             $this->throwExceptionForErrorResponse($data, $e);
         } catch (InvalidResponseError $de) {
             throw new InvalidRequestError($message, $code, $e);
         }
     } catch (ServerErrorResponseException $e) {
         throw new CommunicationError("Error performing request", $e->getCode(), $e);
     }
     $data = $this->jsonDecodeData($response->getBody(true));
     // If debug response with data in the "response" attribute return that
     return isset($data["response"]) ? $data["response"] : $data;
 }
开发者ID:ThemeSurgeon,项目名称:launchkey-php,代码行数:34,代码来源:GuzzleApiService.php

示例13: throwTooManyRedirectsException

 /**
  * Throw a too many redirects exception for a request
  *
  * @param RequestInterface $request Request
  * @throws TooManyRedirectsException when too many redirects have been issued
  */
 protected function throwTooManyRedirectsException(RequestInterface $request)
 {
     $responses = array();
     // Create a nice message to use when throwing the exception that shows each request/response transaction
     do {
         $response = $request->getResponse();
         $responses[] = '> ' . $request->getRawHeaders() . "\n\n< " . $response->getRawHeaders();
         $request = $response->getPreviousResponse() ? $response->getPreviousResponse()->getRequest() : null;
     } while ($request);
     $transaction = implode("* Sending redirect request\n", array_reverse($responses));
     throw new TooManyRedirectsException("Too many redirects were issued for this transaction:\n{$transaction}");
 }
开发者ID:unkerror,项目名称:Budabot,代码行数:18,代码来源:RedirectPlugin.php

示例14: runRequest

 /**
  * Run guzzle request
  *
  * @param RequestInterface $request
  *
  * @return array
  */
 private function runRequest(RequestInterface $request)
 {
     try {
         $request->send();
         //send the req and return the json
         return $request->getResponse()->json();
     } catch (Exception $e) {
         return array('error' => $request->getResponse()->json());
     }
 }
开发者ID:hd-deman,项目名称:elcodi,代码行数:17,代码来源:OpenExchangeRatesProviderAdapter.php


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