MediaWiki REL1_34
|
An HTTP 1.0 client built for the purposes of purging Squid and Varnish. More...
Public Member Functions | |
__construct ( $server) | |
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 | |
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) | |
Protected Attributes | |
int | $bodyRemaining |
mixed | $currentRequestIndex |
string | $host |
string bool | $ip |
int | $port |
string | $readBuffer |
string | $readState = 'idle' |
array | $requests = [] |
resource null | $socket |
The socket resource, or null for unconnected, or false for disabled due to error. | |
string | $writeBuffer = '' |
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.
Definition at line 30 of file SquidPurgeClient.php.
SquidPurgeClient::__construct | ( | $server | ) |
string | $server |
Definition at line 72 of file SquidPurgeClient.php.
SquidPurgeClient::close | ( | ) |
Close the socket but allow it to be reopened for future purge requests.
Definition at line 178 of file SquidPurgeClient.php.
Referenced by doReads(), and markDown().
SquidPurgeClient::doReads | ( | ) |
Read some data.
Call this when socket_select() indicates that the read buffer is non-empty.
Definition at line 274 of file SquidPurgeClient.php.
References $socket, close(), getSocket(), log(), markDown(), and processReadBuffer().
SquidPurgeClient::doWrites | ( | ) |
Perform pending writes.
Call this when socket_select() indicates that writing will not block.
Definition at line 239 of file SquidPurgeClient.php.
References $socket, $writeBuffer, getSocket(), log(), and markDown().
|
protected |
Get the host's IP address.
Does not support IPv6 at present due to the lack of a convenient interface in PHP.
MWException |
Definition at line 148 of file SquidPurgeClient.php.
Referenced by getSocket().
SquidPurgeClient::getReadSocketsForSelect | ( | ) |
Get read socket array for select()
Definition at line 116 of file SquidPurgeClient.php.
References $socket, and getSocket().
|
protected |
Open a socket if there isn't one open already, return it.
Returns false on error.
Definition at line 84 of file SquidPurgeClient.php.
References $ip, $socket, getIP(), log(), and markDown().
Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().
SquidPurgeClient::getWriteSocketsForSelect | ( | ) |
Get write socket array for select()
Definition at line 131 of file SquidPurgeClient.php.
References $socket, and getSocket().
SquidPurgeClient::isIdle | ( | ) |
Definition at line 232 of file SquidPurgeClient.php.
|
protected |
string | $msg |
Definition at line 393 of file SquidPurgeClient.php.
References wfDebugLog().
Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().
|
protected |
Close the socket and ignore any future purge requests.
This is called if there is a protocol error.
Definition at line 170 of file SquidPurgeClient.php.
References close().
Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().
|
protected |
Definition at line 374 of file SquidPurgeClient.php.
References $currentRequestIndex.
Referenced by processReadBuffer(), and queuePurge().
|
protected |
string | $line |
Definition at line 366 of file SquidPurgeClient.php.
References $line.
Referenced by processReadBuffer().
|
protected |
MWException |
Definition at line 305 of file SquidPurgeClient.php.
References $lines, nextRequest(), processHeaderLine(), and processStatusLine().
Referenced by doReads().
|
protected |
string | $line |
Definition at line 347 of file SquidPurgeClient.php.
References $line, log(), and markDown().
Referenced by processReadBuffer().
SquidPurgeClient::queuePurge | ( | $url | ) |
Queue a purge operation.
string | $url | Fully expanded URL (with host and protocol) |
Definition at line 196 of file SquidPurgeClient.php.
References $host, $path, $wgSquidPurgeUseHostHeader, nextRequest(), Http\userAgent(), wfAppendQuery(), wfDeprecated(), and wfParseUrl().
|
protected |
Definition at line 67 of file SquidPurgeClient.php.
|
protected |
Definition at line 50 of file SquidPurgeClient.php.
Referenced by nextRequest().
|
protected |
Definition at line 32 of file SquidPurgeClient.php.
Referenced by getIP(), and queuePurge().
|
protected |
Definition at line 38 of file SquidPurgeClient.php.
Referenced by getIP(), and getSocket().
|
protected |
Definition at line 35 of file SquidPurgeClient.php.
|
protected |
Definition at line 64 of file SquidPurgeClient.php.
|
protected |
Definition at line 41 of file SquidPurgeClient.php.
|
protected |
Definition at line 47 of file SquidPurgeClient.php.
|
protected |
The socket resource, or null for unconnected, or false for disabled due to error.
Definition at line 61 of file SquidPurgeClient.php.
Referenced by doReads(), doWrites(), getReadSocketsForSelect(), getSocket(), and getWriteSocketsForSelect().
|
protected |
Definition at line 44 of file SquidPurgeClient.php.
Referenced by doWrites().
const SquidPurgeClient::BUFFER_SIZE = 8192 |
Definition at line 55 of file SquidPurgeClient.php.
const SquidPurgeClient::EAGAIN = 11 |
Definition at line 53 of file SquidPurgeClient.php.
const SquidPurgeClient::EINPROGRESS = 115 |
Definition at line 54 of file SquidPurgeClient.php.
const SquidPurgeClient::EINTR = 4 |
Definition at line 52 of file SquidPurgeClient.php.