X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fhttp%2FHttp.php;h=4f21ce2775c6a513e257bb740c0b977d5b6c67f1;hp=fa2d5a385f581285d0e6d1e4c9e0ea547889d09c;hb=7f3d6713e7191c476adb3d3c30344a0327b853d3;hpb=bdfa96eb726c9997a010f5a194eec71925bfddc2 diff --git a/includes/http/Http.php b/includes/http/Http.php index fa2d5a385f..4f21ce2775 100644 --- a/includes/http/Http.php +++ b/includes/http/Http.php @@ -53,11 +53,14 @@ class Http { * - logger A \Psr\Logger\LoggerInterface instance for debug logging * - username Username for HTTP Basic Authentication * - password Password for HTTP Basic Authentication + * - originalRequest Information about the original request (as a WebRequest object or + * an associative array with 'ip' and 'userAgent'). * @param string $caller The method making this request, for profiling * @return string|bool (bool)false on failure or a string on success */ public static function request( $method, $url, $options = [], $caller = __METHOD__ ) { - wfDebug( "HTTP: $method: $url\n" ); + $logger = LoggerFactory::getInstance( 'http' ); + $logger->debug( "$method: $url" ); $options['method'] = strtoupper( $method ); @@ -75,7 +78,6 @@ class Http { return $req->getContent(); } else { $errors = $status->getErrorsByType( 'error' ); - $logger = LoggerFactory::getInstance( 'http' ); $logger->warning( Status::wrap( $status )->getWikiText( false, false, 'en' ), [ 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ] ); return false; @@ -162,4 +164,20 @@ class Http { return ""; } + + /** + * Get a configured MultiHttpClient + * @param array $options + */ + public static function createMultiClient( $options = [] ) { + global $wgHTTPConnectTimeout, $wgHTTPTimeout, $wgHTTPProxy; + + return new MultiHttpClient( $options + [ + 'connTimeout' => $wgHTTPConnectTimeout, + 'reqTimeout' => $wgHTTPTimeout, + 'userAgent' => self::userAgent(), + 'proxy' => $wgHTTPProxy, + 'logger' => LoggerFactory::getInstance( 'http' ) + ] ); + } }