MediaWiki REL1_35
SquidPurgeClient Class Reference

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 = SOCKET_EAGAIN
 
const EINPROGRESS = SOCKET_EINPROGRESS
 
const EINTR = SOCKET_EINTR
 

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 false 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.

Deprecated:
Since 1.35 Use MultiHttpClient

Definition at line 32 of file SquidPurgeClient.php.

Constructor & Destructor Documentation

◆ __construct()

SquidPurgeClient::__construct (   $server)
Parameters
string$server

Definition at line 74 of file SquidPurgeClient.php.

Member Function Documentation

◆ close()

SquidPurgeClient::close ( )

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

Definition at line 180 of file SquidPurgeClient.php.

Referenced by doReads(), and markDown().

◆ doReads()

SquidPurgeClient::doReads ( )

Read some data.

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

Definition at line 277 of file SquidPurgeClient.php.

References $socket, close(), getSocket(), log(), markDown(), and processReadBuffer().

◆ doWrites()

SquidPurgeClient::doWrites ( )

Perform pending writes.

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

Definition at line 242 of file SquidPurgeClient.php.

References $socket, $writeBuffer, getSocket(), log(), and markDown().

◆ getIP()

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 150 of file SquidPurgeClient.php.

References $host, and $ip.

Referenced by getSocket().

◆ getReadSocketsForSelect()

SquidPurgeClient::getReadSocketsForSelect ( )

Get read socket array for select()

Returns
array

Definition at line 118 of file SquidPurgeClient.php.

References $socket, and getSocket().

◆ getSocket()

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 86 of file SquidPurgeClient.php.

References $ip, $socket, getIP(), log(), and markDown().

Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().

◆ getWriteSocketsForSelect()

SquidPurgeClient::getWriteSocketsForSelect ( )

Get write socket array for select()

Returns
array

Definition at line 133 of file SquidPurgeClient.php.

References $socket, and getSocket().

◆ isIdle()

SquidPurgeClient::isIdle ( )
Returns
bool

Definition at line 235 of file SquidPurgeClient.php.

◆ log()

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

Definition at line 396 of file SquidPurgeClient.php.

References wfDebugLog().

Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().

◆ markDown()

SquidPurgeClient::markDown ( )
protected

Close the socket and ignore any future purge requests.

This is called if there is a protocol error.

Definition at line 172 of file SquidPurgeClient.php.

References close().

Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().

◆ nextRequest()

SquidPurgeClient::nextRequest ( )
protected

Definition at line 377 of file SquidPurgeClient.php.

References $currentRequestIndex.

Referenced by processReadBuffer(), and queuePurge().

◆ processHeaderLine()

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

Definition at line 369 of file SquidPurgeClient.php.

References $line.

Referenced by processReadBuffer().

◆ processReadBuffer()

SquidPurgeClient::processReadBuffer ( )
protected
Exceptions
MWException
Returns
string

Definition at line 308 of file SquidPurgeClient.php.

References $lines, nextRequest(), processHeaderLine(), and processStatusLine().

Referenced by doReads().

◆ processStatusLine()

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

Definition at line 350 of file SquidPurgeClient.php.

References $line, log(), and markDown().

Referenced by processReadBuffer().

◆ queuePurge()

SquidPurgeClient::queuePurge (   $url)

Queue a purge operation.

Parameters
string$urlFully expanded URL (with host and protocol)

Definition at line 198 of file SquidPurgeClient.php.

References $host, $path, $wgSquidPurgeUseHostHeader, nextRequest(), Http\userAgent(), wfAppendQuery(), wfDeprecated(), and wfParseUrl().

Member Data Documentation

◆ $bodyRemaining

int SquidPurgeClient::$bodyRemaining
protected

Definition at line 69 of file SquidPurgeClient.php.

◆ $currentRequestIndex

mixed SquidPurgeClient::$currentRequestIndex
protected

Definition at line 52 of file SquidPurgeClient.php.

Referenced by nextRequest().

◆ $host

string SquidPurgeClient::$host
protected

Definition at line 34 of file SquidPurgeClient.php.

Referenced by getIP(), and queuePurge().

◆ $ip

string bool SquidPurgeClient::$ip
protected

Definition at line 40 of file SquidPurgeClient.php.

Referenced by getIP(), and getSocket().

◆ $port

int SquidPurgeClient::$port
protected

Definition at line 37 of file SquidPurgeClient.php.

◆ $readBuffer

string SquidPurgeClient::$readBuffer
protected

Definition at line 66 of file SquidPurgeClient.php.

◆ $readState

string SquidPurgeClient::$readState = 'idle'
protected

Definition at line 43 of file SquidPurgeClient.php.

◆ $requests

array SquidPurgeClient::$requests = []
protected

Definition at line 49 of file SquidPurgeClient.php.

◆ $socket

resource false null SquidPurgeClient::$socket
protected

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

Definition at line 63 of file SquidPurgeClient.php.

Referenced by doReads(), doWrites(), getReadSocketsForSelect(), getSocket(), and getWriteSocketsForSelect().

◆ $writeBuffer

string SquidPurgeClient::$writeBuffer = ''
protected

Definition at line 46 of file SquidPurgeClient.php.

Referenced by doWrites().

◆ BUFFER_SIZE

const SquidPurgeClient::BUFFER_SIZE = 8192

Definition at line 57 of file SquidPurgeClient.php.

◆ EAGAIN

const SquidPurgeClient::EAGAIN = SOCKET_EAGAIN

Definition at line 55 of file SquidPurgeClient.php.

◆ EINPROGRESS

const SquidPurgeClient::EINPROGRESS = SOCKET_EINPROGRESS

Definition at line 56 of file SquidPurgeClient.php.

◆ EINTR

const SquidPurgeClient::EINTR = SOCKET_EINTR

Definition at line 54 of file SquidPurgeClient.php.


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