'http://localhost:4339/document', 'timeout' => 10, 'connectTimeout' => 0.5, ] ); } public function tidy( $text ) { $wrappedtext = '' . '' . $text . ''; $req = MWHttpRequest::factory( $this->config['url'], [ 'method' => 'POST', 'timeout' => $this->config['timeout'], 'connectTimeout' => $this->config['connectTimeout'], 'postData' => [ 'text' => $wrappedtext ] ] ); $status = $req->execute(); if ( !$status->isOK() ) { throw new Exception( "Error contacting depurate service: " . $status->getWikiText( false, false, 'en' ) ); } elseif ( $req->getStatus() !== 200 ) { throw new Exception( "Depurate returned error: " . $status->getWikiText( false, false, 'en' ) ); } $result = $req->getContent(); $startBody = strpos( $result, "" ); $endBody = strrpos( $result, "" ); if ( $startBody !== false && $endBody !== false && $endBody > $startBody ) { $startBody += strlen( "" ); return substr( $result, $startBody, $endBody - $startBody ); } else { return $text . "\n"; } } }