/**
* Open a socket if there isn't one open already, return it.
* Returns false on error.
+ *
+ * @return false|resource
*/
protected function getSocket() {
if ( $this->socket !== null ) {
/**
* Get read socket array for select()
+ * @return array
*/
public function getReadSocketsForSelect() {
if ( $this->readState == 'idle' ) {
/**
* Get write socket array for select()
+ * @return array
*/
public function getWriteSocketsForSelect() {
if ( !strlen( $this->writeBuffer ) ) {
/**
* Queue a purge operation
+ *
+ * @param $url string
*/
public function queuePurge( $url ) {
- $url = str_replace( "\n", '', $url );
+ $url = SquidUpdate::expand( str_replace( "\n", '', $url ) );
$this->requests[] = "PURGE $url HTTP/1.0\r\n" .
"Connection: Keep-Alive\r\n" .
"Proxy-Connection: Keep-Alive\r\n" .
}
}
+ /**
+ * @return bool
+ */
public function isIdle() {
return strlen( $this->writeBuffer ) == 0 && $this->readState == 'idle';
}
while ( $this->socket && $this->processReadBuffer() === 'continue' );
}
+ /**
+ * @throws MWException
+ * @return string
+ */
protected function processReadBuffer() {
switch ( $this->readState ) {
case 'idle':
}
}
+ /**
+ * @param $line
+ * @return
+ */
protected function processStatusLine( $line ) {
if ( !preg_match( '!^HTTP/(\d+)\.(\d+) (\d{3}) (.*)$!', $line, $m ) ) {
$this->log( 'invalid status line' );
$this->readState = 'header';
}
+ /**
+ * @param $line string
+ */
protected function processHeaderLine( $line ) {
if ( preg_match( '/^Content-Length: (\d+)$/i', $line, $m ) ) {
$this->bodyRemaining = intval( $m[1] );