http://www.mediawiki.org/wiki/Special:Code/MediaWiki/62168

Revision: 62168
Author:   mah
Date:     2010-02-09 06:18:53 +0000 (Tue, 09 Feb 2010)

Log Message:
-----------
Fix Http::request() so that it continues to return false on non-200 requests.

Modified Paths:
--------------
    trunk/phase3/includes/HttpFunctions.php
    trunk/phase3/maintenance/tests/HttpTest.php

Modified: trunk/phase3/includes/HttpFunctions.php
===================================================================
--- trunk/phase3/includes/HttpFunctions.php     2010-02-09 06:12:15 UTC (rev 
62167)
+++ trunk/phase3/includes/HttpFunctions.php     2010-02-09 06:18:53 UTC (rev 
62168)
@@ -140,7 +140,7 @@
 
        protected $headerList = array();
        protected $respVersion = "0.9";
-       protected $respStatus = "0.1";
+       protected $respStatus = "200 Ok";
        protected $respHeaders = array();
 
        public $status;
@@ -258,8 +258,8 @@
 
                if( $this->cookieJar ) {
                        $this->reqHeaders['Cookie'] =
-                               
$this->cookieJar->serializeToHttpRequest($this->parsedURL['path'],
-                                                                               
                                 $this->parsedURL['host']);
+                               
$this->cookieJar->serializeToHttpRequest($this->parsedUrl['path'],
+                                                                               
                                 $this->parsedUrl['host']);
                }
                foreach($this->reqHeaders as $name => $value) {
                        $list[] = "$name: $value";
@@ -333,6 +333,9 @@
                        }
                }
 
+               if((int)$this->respStatus !== 200) {
+                       $this->status->fatal('Not Ok');
+               }
                $this->parseCookies();
        }
 
@@ -707,6 +710,7 @@
 
                curl_close( $curlHandle );
 
+               $this->parseHeader();
                return $this->status;
        }
 }
@@ -720,7 +724,7 @@
 
        public function execute() {
                if ( $this->parsedUrl['scheme'] != 'http' ) {
-                       $this->status->fatal( 'http-invalid-scheme', 
$this->parsedURL['scheme'] );
+                       $this->status->fatal( 'http-invalid-scheme', 
$this->parsedUrl['scheme'] );
                }
 
                parent::execute();
@@ -795,6 +799,7 @@
                }
                fclose( $fh );
 
+               $this->parseHeader();
                return $this->status;
        }
 }

Modified: trunk/phase3/maintenance/tests/HttpTest.php
===================================================================
--- trunk/phase3/maintenance/tests/HttpTest.php 2010-02-09 06:12:15 UTC (rev 
62167)
+++ trunk/phase3/maintenance/tests/HttpTest.php 2010-02-09 06:18:53 UTC (rev 
62168)
@@ -109,6 +109,9 @@
                $this->assertLessThan($timeout+2, $end_time - $start_time,
                                                          "Request took less 
than {$timeout}s via ".Http::$httpEngine);
                $this->assertEquals($r, false, "false -- what we get on error 
from Http::get()");
+
+               $r = HTTP::get( 
"http://www.example.com/this-file-does-not-exist";, $timeout);
+               $this->assertFalse($r, "False on 404s");
        }
 
        function testFailureDefault() {



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to