Added non-parallel fallback to MultiHttpClient when curl is unavailable
[lhc/web/wiklou.git] / includes / http / MWHttpRequest.php
index 71e08a8..257955c 100644 (file)
@@ -332,6 +332,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
                if ( is_null( $callback ) ) {
                        $callback = [ $this, 'read' ];
                } elseif ( !is_callable( $callback ) ) {
+                       $this->status->fatal( 'http-internal-error' );
                        throw new InvalidArgumentException( __METHOD__ . ': invalid callback' );
                }
                $this->callback = $callback;
@@ -387,6 +388,11 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
        protected function parseHeader() {
                $lastname = "";
 
+               // Failure without (valid) headers gets a response status of zero
+               if ( !$this->status->isOK() ) {
+                       $this->respStatus = '0';
+               }
+
                foreach ( $this->headerList as $header ) {
                        if ( preg_match( "#^HTTP/([0-9.]+) (.*)#", $header, $match ) ) {
                                $this->respVersion = $match[1];