31use Psr\Log\LoggerInterface;
48 'HTTPMaxConnectTimeout',
99 if ( !isset(
$options[
'logger'] ) ) {
105 $this->options->
get(
'HTTPTimeout' ),
106 $this->options->get(
'HTTPMaxTimeout' )
110 $options[
'maxConnectTimeout'] ??
null,
111 $this->options->
get(
'HTTPConnectTimeout' ),
112 $this->options->get(
'HTTPMaxConnectTimeout' )
123 throw new RuntimeException( __METHOD__ .
': The requested engine is not valid.' );
138 if ( $parameter ===
'default' || $parameter ===
null ) {
139 if ( !is_numeric( $default ) ) {
140 throw new \InvalidArgumentException(
141 '$wgHTTPTimeout and $wgHTTPConnectTimeout must be set to a number' );
147 if ( $maxParameter !==
null ) {
148 $max = $maxParameter;
150 $max = $maxConfigured;
152 if ( $max && $value > $max ) {
165 return function_exists(
'curl_init' ) ||
wfIniGetBool(
'allow_url_fopen' );
180 $logger = LoggerFactory::getInstance(
'http' );
181 $logger->debug(
"$method: $url" );
183 $options[
'method'] = strtoupper( $method );
186 $status = $req->execute();
188 if ( $status->isOK() ) {
189 return $req->getContent();
191 $errors = $status->getErrorsByType(
'error' );
192 $logger->warning( Status::wrap( $status )->getWikiText(
false,
false,
'en' ),
193 [
'error' => $errors,
'caller' => $caller,
'content' => $req->getContent() ] );
207 public function get( $url, array
$options = [], $caller = __METHOD__ ) {
220 public function post( $url, array
$options = [], $caller = __METHOD__ ) {
245 $options[
'reqTimeout'] ??
$options[
'timeout'] ??
null,
247 $this->options->
get(
'HTTPTimeout' ),
248 $this->options->get(
'HTTPMaxTimeout' )
251 $options[
'connTimeout'] ??
$options[
'connectTimeout'] ??
null,
253 $this->options->
get(
'HTTPConnectTimeout' ),
254 $this->options->get(
'HTTPMaxConnectTimeout' )
257 'maxReqTimeout' => $this->options->get(
'HTTPMaxTimeout' ),
258 'maxConnTimeout' => $this->options->get(
'HTTPMaxConnectTimeout' ),
const MW_VERSION
The running version of MediaWiki.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
MWHttpRequest implemented using internal curl compiled into PHP.
MWHttpRequest implemented using the Guzzle library.
Various HTTP related functions.
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
Class to handle multiple HTTP requests.
Profiler base class that defines the interface and some shared functionality.
static instance()
Singleton.
Generic operation result class Has warning/error list, boolean status and arbitrary value.