69 public function create( $url, array $options = [], $caller = __METHOD__ ) {
74 if ( !isset( $options[
'logger'] ) ) {
86 throw new RuntimeException( __METHOD__ .
': The requested engine is not valid.' );
96 return function_exists(
'curl_init' ) ||
wfIniGetBool(
'allow_url_fopen' );
110 public function request( $method, $url, array $options = [], $caller = __METHOD__ ) {
112 $logger->debug(
"$method: $url" );
114 $options[
'method'] = strtoupper( $method );
116 if ( !isset( $options[
'timeout'] ) ) {
117 $options[
'timeout'] =
'default';
119 if ( !isset( $options[
'connectTimeout'] ) ) {
120 $options[
'connectTimeout'] =
'default';
123 $req = $this->
create( $url, $options, $caller );
127 return $req->getContent();
129 $errors =
$status->getErrorsByType(
'error' );
131 [
'error' => $errors,
'caller' => $caller,
'content' => $req->getContent() ] );
145 public function get( $url, array $options = [], $caller = __METHOD__ ) {
146 return $this->
request(
'GET', $url, $options, $caller );
158 public function post( $url, array $options = [], $caller = __METHOD__ ) {
159 return $this->
request(
'POST', $url, $options, $caller );
168 return "MediaWiki/$wgVersion";