debug( "$method: $url" ); $options['method'] = strtoupper( $method ); if ( !isset( $options['timeout'] ) ) { $options['timeout'] = 'default'; } if ( !isset( $options['connectTimeout'] ) ) { $options['connectTimeout'] = 'default'; } $req = $this->create( $url, $options, $caller ); $status = $req->execute(); if ( $status->isOK() ) { return $req->getContent(); } else { $errors = $status->getErrorsByType( 'error' ); $logger->warning( Status::wrap( $status )->getWikiText( false, false, 'en' ), [ 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ] ); return null; } } /** * Simple wrapper for request( 'GET' ), parameters have same meaning as for request() * * @since 1.34 * @param string $url * @param array $options * @param string $caller * @return string|null */ public function get( $url, array $options = [], $caller = __METHOD__ ) { return $this->request( 'GET', $url, $options, $caller ); } /** * Simple wrapper for request( 'POST' ), parameters have same meaning as for request() * * @since 1.34 * @param string $url * @param array $options * @param string $caller * @return string|null */ public function post( $url, array $options = [], $caller = __METHOD__ ) { return $this->request( 'POST', $url, $options, $caller ); } /** * @return string */ public function getUserAgent() { global $wgVersion; return "MediaWiki/$wgVersion"; } }