vendor/guzzle/guzzle/src/Guzzle/Plugin/History/HistoryPlugin.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Guzzle\Plugin\History;
use Guzzle\Common\Event;
use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\Response;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Maintains a list of requests and responses sent using a request or client
*/
class HistoryPlugin implements EventSubscriberInterface, \IteratorAggregate, \Countable
{
/** @var int The maximum number of requests to maintain in the history */
protected $limit = 10;
/** @var array Requests and responses that have passed through the plugin */
protected $transactions = array();
public static function getSubscribedEvents()
{
return array('request.sent' => array('onRequestSent', 9999));
}
/**
* Convert to a string that contains all request and response headers
*
* @return string
*/
public function __toString()
{
$lines = array();
foreach ($this->transactions as $entry) {
$response = isset($entry['response']) ? $entry['response'] : '';
$lines[] = '> ' . trim($entry['request']) . "\n\n< " . trim($response) . "\n";
}
return implode("\n", $lines);
}
/**
* 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);
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。