MediaWiki
REL1_20
|
An HTTP 1.0 client built for the purposes of purging Squid and Varnish. More...
Public Member Functions | |
__construct ($server, $options=array()) | |
close () | |
Close the socket but allow it to be reopened for future purge requests. | |
doReads () | |
Read some data. | |
doWrites () | |
Perform pending writes. | |
getReadSocketsForSelect () | |
Get read socket array for select() | |
getWriteSocketsForSelect () | |
Get write socket array for select() | |
isIdle () | |
queuePurge ($url) | |
Queue a purge operation. | |
Public Attributes | |
$bodyRemaining | |
$currentRequestIndex | |
$host | |
$ip | |
$port | |
$readBuffer | |
$readState = 'idle' | |
$requests = array() | |
$socket | |
The socket resource, or null for unconnected, or false for disabled due to error. | |
$writeBuffer = '' | |
const | BUFFER_SIZE = 8192 |
const | EAGAIN = 11 |
const | EINPROGRESS = 115 |
const | EINTR = 4 |
Protected Member Functions | |
getIP () | |
Get the host's IP address. | |
getSocket () | |
Open a socket if there isn't one open already, return it. | |
log ($msg) | |
markDown () | |
Close the socket and ignore any future purge requests. | |
nextRequest () | |
processHeaderLine ($line) | |
processReadBuffer () | |
processStatusLine ($line) |
An HTTP 1.0 client built for the purposes of purging Squid and Varnish.
Uses asynchronous I/O, allowing purges to be done in a highly parallel manner.
Could be replaced by curl_multi_exec() or some such.
Definition at line 30 of file SquidPurgeClient.php.
SquidPurgeClient::__construct | ( | $ | server, |
$ | options = array() |
||
) |
$server | string |
$options | array |
Definition at line 56 of file SquidPurgeClient.php.
Close the socket but allow it to be reopened for future purge requests.
Definition at line 160 of file SquidPurgeClient.php.
References wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by doReads(), and markDown().
Read some data.
Call this when socket_select() indicates that the read buffer is non-empty.
Definition at line 234 of file SquidPurgeClient.php.
References $socket, close(), getSocket(), log(), markDown(), processReadBuffer(), wfRestoreWarnings(), and wfSuppressWarnings().
Perform pending writes.
Call this when socket_select() indicates that writing will not block.
Definition at line 199 of file SquidPurgeClient.php.
References $socket, getSocket(), log(), markDown(), wfRestoreWarnings(), and wfSuppressWarnings().
SquidPurgeClient::getIP | ( | ) | [protected] |
Get the host's IP address.
Does not support IPv6 at present due to the lack of a convenient interface in PHP.
Definition at line 130 of file SquidPurgeClient.php.
References IP\isIPv4(), IP\isIPv6(), wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by getSocket().
Get read socket array for select()
Definition at line 100 of file SquidPurgeClient.php.
References $socket, and getSocket().
SquidPurgeClient::getSocket | ( | ) | [protected] |
Open a socket if there isn't one open already, return it.
Returns false on error.
Definition at line 68 of file SquidPurgeClient.php.
References $ip, $ok, getIP(), log(), markDown(), wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().
Get write socket array for select()
Definition at line 115 of file SquidPurgeClient.php.
References $socket, and getSocket().
Definition at line 192 of file SquidPurgeClient.php.
SquidPurgeClient::log | ( | $ | msg | ) | [protected] |
$msg | string |
Definition at line 354 of file SquidPurgeClient.php.
References wfDebugLog().
Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().
SquidPurgeClient::markDown | ( | ) | [protected] |
Close the socket and ignore any future purge requests.
This is called if there is a protocol error.
Definition at line 152 of file SquidPurgeClient.php.
References close().
Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().
SquidPurgeClient::nextRequest | ( | ) | [protected] |
Definition at line 335 of file SquidPurgeClient.php.
Referenced by processReadBuffer(), and queuePurge().
SquidPurgeClient::processHeaderLine | ( | $ | line | ) | [protected] |
$line | string |
Definition at line 327 of file SquidPurgeClient.php.
Referenced by processReadBuffer().
SquidPurgeClient::processReadBuffer | ( | ) | [protected] |
MWException |
Definition at line 265 of file SquidPurgeClient.php.
References $lines, nextRequest(), processHeaderLine(), and processStatusLine().
Referenced by doReads().
SquidPurgeClient::processStatusLine | ( | $ | line | ) | [protected] |
$line |
Definition at line 308 of file SquidPurgeClient.php.
References log(), and markDown().
Referenced by processReadBuffer().
SquidPurgeClient::queuePurge | ( | $ | url | ) |
Queue a purge operation.
$url | string |
Definition at line 178 of file SquidPurgeClient.php.
References $url, expand, nextRequest(), and Http\userAgent().
SquidPurgeClient::$bodyRemaining |
Definition at line 50 of file SquidPurgeClient.php.
SquidPurgeClient::$currentRequestIndex |
Definition at line 36 of file SquidPurgeClient.php.
SquidPurgeClient::$host |
Definition at line 31 of file SquidPurgeClient.php.
SquidPurgeClient::$ip |
Definition at line 31 of file SquidPurgeClient.php.
Referenced by getSocket().
SquidPurgeClient::$port |
Definition at line 31 of file SquidPurgeClient.php.
SquidPurgeClient::$readBuffer |
Definition at line 48 of file SquidPurgeClient.php.
SquidPurgeClient::$readState = 'idle' |
Definition at line 33 of file SquidPurgeClient.php.
SquidPurgeClient::$requests = array() |
Definition at line 35 of file SquidPurgeClient.php.
SquidPurgeClient::$socket |
The socket resource, or null for unconnected, or false for disabled due to error.
Definition at line 46 of file SquidPurgeClient.php.
Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().
SquidPurgeClient::$writeBuffer = '' |
Definition at line 34 of file SquidPurgeClient.php.
const SquidPurgeClient::BUFFER_SIZE = 8192 |
Definition at line 41 of file SquidPurgeClient.php.
const SquidPurgeClient::EAGAIN = 11 |
Definition at line 39 of file SquidPurgeClient.php.
const SquidPurgeClient::EINPROGRESS = 115 |
Definition at line 40 of file SquidPurgeClient.php.
const SquidPurgeClient::EINTR = 4 |
Definition at line 38 of file SquidPurgeClient.php.