r62168 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62167‎ | r62168 | r62169 >
Date:06:18, 9 February 2010
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Fix Http::request() so that it continues to return false on non-200 requests.
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)
  • /trunk/phase3/maintenance/tests/HttpTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/HttpTest.php
@@ -109,6 +109,9 @@
110110 $this->assertLessThan($timeout+2, $end_time - $start_time,
111111 "Request took less than {$timeout}s via ".Http::$httpEngine);
112112 $this->assertEquals($r, false, "false -- what we get on error from Http::get()");
 113+
 114+ $r = HTTP::get( "http://www.example.com/this-file-does-not-exist", $timeout);
 115+ $this->assertFalse($r, "False on 404s");
113116 }
114117
115118 function testFailureDefault() {
Index: trunk/phase3/includes/HttpFunctions.php
@@ -140,7 +140,7 @@
141141
142142 protected $headerList = array();
143143 protected $respVersion = "0.9";
144 - protected $respStatus = "0.1";
 144+ protected $respStatus = "200 Ok";
145145 protected $respHeaders = array();
146146
147147 public $status;
@@ -258,8 +258,8 @@
259259
260260 if( $this->cookieJar ) {
261261 $this->reqHeaders['Cookie'] =
262 - $this->cookieJar->serializeToHttpRequest($this->parsedURL['path'],
263 - $this->parsedURL['host']);
 262+ $this->cookieJar->serializeToHttpRequest($this->parsedUrl['path'],
 263+ $this->parsedUrl['host']);
264264 }
265265 foreach($this->reqHeaders as $name => $value) {
266266 $list[] = "$name: $value";
@@ -333,6 +333,9 @@
334334 }
335335 }
336336
 337+ if((int)$this->respStatus !== 200) {
 338+ $this->status->fatal('Not Ok');
 339+ }
337340 $this->parseCookies();
338341 }
339342
@@ -707,6 +710,7 @@
708711
709712 curl_close( $curlHandle );
710713
 714+ $this->parseHeader();
711715 return $this->status;
712716 }
713717 }
@@ -720,7 +724,7 @@
721725
722726 public function execute() {
723727 if ( $this->parsedUrl['scheme'] != 'http' ) {
724 - $this->status->fatal( 'http-invalid-scheme', $this->parsedURL['scheme'] );
 728+ $this->status->fatal( 'http-invalid-scheme', $this->parsedUrl['scheme'] );
725729 }
726730
727731 parent::execute();
@@ -795,6 +799,7 @@
796800 }
797801 fclose( $fh );
798802
 803+ $this->parseHeader();
799804 return $this->status;
800805 }
801806 }

Comments

#Comment by Tim Starling (talk | contribs)   23:37, 15 February 2010

Was fixed in r62174.

Status & tagging log