build: Bump mediawiki-phan-config to 0.8.0
[lhc/web/wiklou.git] / includes / libs / http / MultiHttpClient.php
index b195a08..2a080aa 100644 (file)
@@ -176,7 +176,9 @@ class MultiHttpClient implements LoggerAwareInterface {
         * @return bool true if curl is available, false otherwise.
         */
        protected function isCurlEnabled() {
-               return extension_loaded( 'curl' );
+               // Explicitly test if curl_multi* is blocked, as some users' hosts provide
+               // them with a modified curl with the multi-threaded parts removed(!)
+               return extension_loaded( 'curl' ) && function_exists( 'curl_multi_init' );
        }
 
        /**
@@ -385,7 +387,7 @@ class MultiHttpClient implements LoggerAwareInterface {
                                }
                                $length = strlen( $header );
                                $matches = [];
-                               if ( preg_match( "/^(HTTP\/1\.[01]) (\d{3}) (.*)/", $header, $matches ) ) {
+                               if ( preg_match( "/^(HTTP\/(?:1\.[01]|2)) (\d{3}) (.*)/", $header, $matches ) ) {
                                        $req['response']['code'] = (int)$matches[2];
                                        $req['response']['reason'] = trim( $matches[3] );
                                        return $length;
@@ -412,7 +414,6 @@ class MultiHttpClient implements LoggerAwareInterface {
                                if ( $hasOutputStream ) {
                                        return fwrite( $req['stream'], $data );
                                } else {
-                                       // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
                                        $req['response']['body'] .= $data;
 
                                        return strlen( $data );