22 use GuzzleHttp\Client;
30 use Psr\Log\LoggerInterface;
96 if ( !isset(
$options[
'logger'] ) ) {
100 $options[
'timeout'] ??
null,
106 $options[
'connectTimeout'] ??
null,
107 $options[
'maxConnectTimeout'] ??
null,
126 if ( $parameter ===
'default' || $parameter ===
null ) {
127 if ( !is_numeric( $default ) ) {
128 throw new \InvalidArgumentException(
129 '$wgHTTPTimeout and $wgHTTPConnectTimeout must be set to a number' );
135 if ( $maxParameter !==
null ) {
136 $max = $maxParameter;
138 $max = $maxConfigured;
140 if ( $max && $value > $max ) {
153 return function_exists(
'curl_init' ) ||
wfIniGetBool(
'allow_url_fopen' );
169 $logger->debug(
"$method: $url" );
171 $options[
'method'] = strtoupper( $method );
174 $status = $req->execute();
176 if ( $status->isOK() ) {
177 return $req->getContent();
179 $errors = $status->getErrorsByType(
'error' );
181 [
'error' => $errors,
'caller' => $caller,
'content' => $req->getContent() ] );
195 public function get( $url, array
$options = [], $caller = __METHOD__ ) {
208 public function post( $url, array
$options = [], $caller = __METHOD__ ) {
233 $options[
'reqTimeout'] ??
$options[
'timeout'] ??
null,
239 $options[
'connTimeout'] ??
$options[
'connectTimeout'] ??
null,
278 $config[
'connect_timeout'] ??
null,
279 $config[
'maxConnectTimeout'] ??
null,
284 if ( !isset(
$config[
'headers'][
'User-Agent'] ) ) {
const MW_VERSION
The running version of MediaWiki.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
MWHttpRequest implemented using the Guzzle library.
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
A class containing constants representing the names of configuration variables.
const HTTPConnectTimeout
Name constant for the HTTPConnectTimeout setting, for use with Config::get()
const HTTPTimeout
Name constant for the HTTPTimeout setting, for use with Config::get()
const LocalVirtualHosts
Name constant for the LocalVirtualHosts setting, for use with Config::get()
const HTTPMaxConnectTimeout
Name constant for the HTTPMaxConnectTimeout setting, for use with Config::get()
const HTTPMaxTimeout
Name constant for the HTTPMaxTimeout setting, for use with Config::get()
const LocalHTTPProxy
Name constant for the LocalHTTPProxy setting, for use with Config::get()
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.
static wrap( $sv)
Succinct helper method to wrap a StatusValue.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".