Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/guzzle/guzzle/src/Guzzle/Plugin/Cookie
File: CookiePlugin.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Guzzle\Plugin\Cookie;
[2] Fix | Delete
[3] Fix | Delete
use Guzzle\Common\Event;
[4] Fix | Delete
use Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar;
[5] Fix | Delete
use Guzzle\Plugin\Cookie\CookieJar\CookieJarInterface;
[6] Fix | Delete
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Adds, extracts, and persists cookies between HTTP requests
[10] Fix | Delete
*/
[11] Fix | Delete
class CookiePlugin implements EventSubscriberInterface
[12] Fix | Delete
{
[13] Fix | Delete
/** @var CookieJarInterface Cookie cookieJar used to hold cookies */
[14] Fix | Delete
protected $cookieJar;
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* @param CookieJarInterface $cookieJar Cookie jar used to hold cookies. Creates an ArrayCookieJar by default.
[18] Fix | Delete
*/
[19] Fix | Delete
public function __construct(CookieJarInterface $cookieJar = null)
[20] Fix | Delete
{
[21] Fix | Delete
$this->cookieJar = $cookieJar ?: new ArrayCookieJar();
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
public static function getSubscribedEvents()
[25] Fix | Delete
{
[26] Fix | Delete
return array(
[27] Fix | Delete
'request.before_send' => array('onRequestBeforeSend', 125),
[28] Fix | Delete
'request.sent' => array('onRequestSent', 125)
[29] Fix | Delete
);
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Get the cookie cookieJar
[34] Fix | Delete
*
[35] Fix | Delete
* @return CookieJarInterface
[36] Fix | Delete
*/
[37] Fix | Delete
public function getCookieJar()
[38] Fix | Delete
{
[39] Fix | Delete
return $this->cookieJar;
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Add cookies before a request is sent
[44] Fix | Delete
*
[45] Fix | Delete
* @param Event $event
[46] Fix | Delete
*/
[47] Fix | Delete
public function onRequestBeforeSend(Event $event)
[48] Fix | Delete
{
[49] Fix | Delete
$request = $event['request'];
[50] Fix | Delete
if (!$request->getParams()->get('cookies.disable')) {
[51] Fix | Delete
$request->removeHeader('Cookie');
[52] Fix | Delete
// Find cookies that match this request
[53] Fix | Delete
foreach ($this->cookieJar->getMatchingCookies($request) as $cookie) {
[54] Fix | Delete
$request->addCookie($cookie->getName(), $cookie->getValue());
[55] Fix | Delete
}
[56] Fix | Delete
}
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Extract cookies from a sent request
[61] Fix | Delete
*
[62] Fix | Delete
* @param Event $event
[63] Fix | Delete
*/
[64] Fix | Delete
public function onRequestSent(Event $event)
[65] Fix | Delete
{
[66] Fix | Delete
$this->cookieJar->addCookiesFromResponse($event['response'], $event['request']);
[67] Fix | Delete
}
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function