MediaWiki  REL1_24
SquidPurgeClient Class Reference

An HTTP 1.0 client built for the purposes of purging Squid and Varnish. More...

Collaboration diagram for SquidPurgeClient:

List of all members.

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

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 = array()
 *
resource null $socket
 The socket resource, or null for unconnected, or false for disabled due to error.
string $writeBuffer = ''
 *

Detailed Description

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.


Constructor & Destructor Documentation

SquidPurgeClient::__construct ( server,
options = array() 
)
Parameters:
string$server
array$options

Definition at line 63 of file SquidPurgeClient.php.


Member Function Documentation

Close the socket but allow it to be reopened for future purge requests.

Definition at line 169 of file SquidPurgeClient.php.

Read some data.

Call this when socket_select() indicates that the read buffer is non-empty.

Definition at line 264 of file SquidPurgeClient.php.

Perform pending writes.

Call this when socket_select() indicates that writing will not block.

Definition at line 229 of file SquidPurgeClient.php.

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.

Exceptions:
MWException
Returns:
string

Definition at line 139 of file SquidPurgeClient.php.

Get read socket array for select()

Returns:
array

Definition at line 107 of file SquidPurgeClient.php.

SquidPurgeClient::getSocket ( ) [protected]

Open a socket if there isn't one open already, return it.

Returns false on error.

Returns:
bool|resource

Definition at line 75 of file SquidPurgeClient.php.

Get write socket array for select()

Returns:
array

Definition at line 122 of file SquidPurgeClient.php.

References array().

Returns:
bool

Definition at line 222 of file SquidPurgeClient.php.

SquidPurgeClient::log ( msg) [protected]
Parameters:
string$msg

Definition at line 383 of file SquidPurgeClient.php.

SquidPurgeClient::markDown ( ) [protected]

Close the socket and ignore any future purge requests.

This is called if there is a protocol error.

Definition at line 161 of file SquidPurgeClient.php.

Definition at line 364 of file SquidPurgeClient.php.

SquidPurgeClient::processHeaderLine ( line) [protected]
Parameters:
string$line

Definition at line 356 of file SquidPurgeClient.php.

Exceptions:
MWException
Returns:
string

Definition at line 295 of file SquidPurgeClient.php.

SquidPurgeClient::processStatusLine ( line) [protected]
Parameters:
string$line

Definition at line 337 of file SquidPurgeClient.php.

Queue a purge operation.

Parameters:
string$url

Definition at line 187 of file SquidPurgeClient.php.


Member Data Documentation

int SquidPurgeClient::$bodyRemaining [protected]

*

Definition at line 57 of file SquidPurgeClient.php.

mixed SquidPurgeClient::$currentRequestIndex [protected]

*

Definition at line 43 of file SquidPurgeClient.php.

string SquidPurgeClient::$host [protected]

*

Definition at line 31 of file SquidPurgeClient.php.

string bool SquidPurgeClient::$ip [protected]

*

Definition at line 35 of file SquidPurgeClient.php.

int SquidPurgeClient::$port [protected]

*

Definition at line 33 of file SquidPurgeClient.php.

string SquidPurgeClient::$readBuffer [protected]

*

Definition at line 55 of file SquidPurgeClient.php.

string SquidPurgeClient::$readState = 'idle' [protected]

*

Definition at line 37 of file SquidPurgeClient.php.

array SquidPurgeClient::$requests = array() [protected]

*

Definition at line 41 of file SquidPurgeClient.php.

resource null SquidPurgeClient::$socket [protected]

The socket resource, or null for unconnected, or false for disabled due to error.

Definition at line 53 of file SquidPurgeClient.php.

string SquidPurgeClient::$writeBuffer = '' [protected]

*

Definition at line 39 of file SquidPurgeClient.php.

Definition at line 48 of file SquidPurgeClient.php.

Definition at line 46 of file SquidPurgeClient.php.

Definition at line 47 of file SquidPurgeClient.php.

Definition at line 45 of file SquidPurgeClient.php.


The documentation for this class was generated from the following file: